View
extension View
-
Adds an independent line on top of FilledLineChart.
Allows for a hard line over the data point with a semi opaque fill.
Requires
Chart Data to conform to CTLineChartDataProtocol.- LineChartData
Available for:
- Filled Line Chart
Unavailable for:
- Line Chart
- Multi Line Chart
- Ranged Line Chart
- Bar Chart
- Grouped Bar Chart
- Stacked Bar Chart
- Ranged Bar Chart
- Pie Chart
Doughnut Chart
Declaration
Swift
public func filledTopLine<T: LineChartData>( chartData: T, lineColour: ColourStyle = ColourStyle(), strokeStyle: StrokeStyle = StrokeStyle() ) -> some ViewParameters
chartDataChart data model.
lineColourLine Colour
strokeStyleStroke Style
Return Value
A new view containing the chart with point markers.
-
Lays out markers over each of the data point.
The style of the markers is set in the PointStyle data model as parameter in the Chart Data.
Requires
Chart Data to conform to CTLineChartDataProtocol.- LineChartData
- MultiLineChartData
Available for:
- Line Chart
- Multi Line Chart
- Filled Line Chart
- Ranged Line Chart
Unavailable for:
- Bar Chart
- Grouped Bar Chart
- Stacked Bar Chart
- Ranged Bar Chart
- Pie Chart
Doughnut Chart
Declaration
Swift
public func pointMarkers<T>(chartData: T) -> some View where T : CTLineChartDataProtocol, T : GetDataProtocolParameters
chartDataChart data model.
Return Value
A new view containing the chart with point markers.
-
Displays the metadata about the chart.
Adds a view above the chart that displays the title and subtitle. If infoBoxPlacement is set to .header then the datapoint info will be displayed here as well.
Declaration
Swift
public func headerBox<T>(chartData: T) -> some View where T : CTChartDataParameters
chartDataChart data model.
Return Value
A new view containing the chart with a view above to display metadata.
-
Displays legends under the chart.
Declaration
Swift
public func legends<T:CTChartData>( chartData: T, columns: [GridItem] = [GridItem(.flexible())], iconWidth: CGFloat = 40, font: Font = .caption, textColor: Color = Color.primary, topPadding: CGFloat = 18 ) -> some ViewParameters
chartDataChart data model.
columnsHow to layout the legends.
textColorColour of the text.
Return Value
A new view containing the chart with chart legends under.
-
Adds touch interaction with the chart.
Adds an overlay to detect touch and display the relivent information from the nearest data point.
Requires
If ChartStyle –> infoBoxPlacement is set to .header then.headerBoxis required.If ChartStyle –> infoBoxPlacement is set to .infoBox then
.infoBoxis required.If ChartStyle –> infoBoxPlacement is set to .floating then
.floatingInfoBoxis required.Attention
Unavailable in tvOS
Declaration
Swift
public func touchOverlay<T: CTChartData>( chartData: T, specifier: String = "%.0f", formatter: NumberFormatter? = nil, unit: TouchUnit = .none, minDistance: CGFloat = 0 ) -> some ViewParameters
chartDataChart data model.
specifierDecimal precision for labels.
unitUnit to put before or after the value.
minDistanceThe distance that the touch event needs to travel to register.
Return Value
A new view containing the chart with a touch overlay.
-
Adds touch interaction with the chart.
Attention
Unavailable in tvOS -
Undocumented
Declaration
Swift
public func disableAnimation<ChartData>(chartData: ChartData, _ value: Bool = true) -> some View where ChartData : CTChartData
-
Adds an seperate line that is over-layed on top of a other chart.
Requires
Chart Data to conform to CTLineBarChartDataProtocol.
Declaration
Swift
public func extraLine<T: CTLineBarChartDataProtocol>( chartData: T, legendTitle: String, datapoints: @escaping () -> ([ExtraLineDataPoint]), style: @escaping () -> (ExtraLineStyle) ) -> some ViewParameters
chartDataData that conforms to CTLineBarChartDataProtocol.
legendTitleTitle of the extra line to display in the legends.
datapointsData point to create the line.
styleStyling data for the line.
Return Value
The chart with an extra line stacked on top.
-
Adds an seperate line that is over-layed on top of a other chart.
Requires
Chart Data to conform to CTLineBarChartDataProtocol.
Declaration
Swift
public func extraLine<T: CTLineBarChartDataProtocol>( chartData: T, legendTitle: String, datapoints: @escaping @autoclosure () -> ([ExtraLineDataPoint]), style: @escaping @autoclosure () -> (ExtraLineStyle) ) -> some ViewParameters
chartDataData that conforms to CTLineBarChartDataProtocol.
legendTitleTitle of the extra line to display in the legends.
datapointsData point to create the line.
styleStyling data for the line.
Return Value
The chart with an extra line stacked on top.
-
Adds a second set of Y axis labels.
Declaration
Swift
public func extraYAxisLabels<T: CTLineBarChartDataProtocol>( chartData: T, specifier: String = "%.0f", colourIndicator: AxisColour = .none ) -> some ViewParameters
chartDataData that conforms to CTLineBarChartDataProtocol.
specifierDecimal precision for labels.
colourIndicatorSecond Y Axis style.
Return Value
A View with second set of Y axis labels.
-
A view that displays information from
TouchOverlay.Places the info box on top of the chart.
Declaration
Swift
public func floatingInfoBox<T>(chartData: T) -> some View where T : CTLineBarChartDataProtocolParameters
chartDataChart data model.
Return Value
A new view containing the chart with a view to display touch overlay information.
-
A view that displays information from
TouchOverlay.Places the info box on top of the chart.
Declaration
Swift
public func floatingInfoBox<T>(chartData: T) -> some View where T : CTLineBarChartDataProtocol, T : isHorizontalParameters
chartDataChart data model.
Return Value
A new view containing the chart with a view to display touch overlay information.
-
A view that displays information from
TouchOverlay.Declaration
Swift
public func infoBox<T: CTLineBarChartDataProtocol>( chartData: T, height: CGFloat = 70 ) -> some ViewParameters
chartDataChart data model.
Return Value
A new view containing the chart with a view to display touch overlay information.
-
A view that displays information from
TouchOverlay.Declaration
Swift
public func infoBox<T: CTLineBarChartDataProtocol & isHorizontal>( chartData: T, width: CGFloat = 70 ) -> some ViewParameters
chartDataChart data model.
widthWidth of the view.
Return Value
A new view containing the chart with a view to display touch overlay information.
-
Draws a line across the chart to show the the trend in the data.
Declaration
Swift
public func linearTrendLine<T: CTLineBarChartDataProtocol & GetDataProtocol>( chartData: T, firstValue: Double, lastValue: Double, lineColour: ColourStyle = ColourStyle(), strokeStyle: StrokeStyle = StrokeStyle() ) -> some ViewParameters
chartDataChart data model.
firstValueThe value of the leading data point.
lastValueThe value of the trailnig data point.
lineColourLine Colour.
strokeStyleStroke Style.
Return Value
A new view containing the chart with a trend line.
-
Adds vertical lines along the X axis.
The style is set in ChartData –> ChartStyle –> xAxisGridStyle
Requires
Chart Data to conform to CTLineBarChartDataProtocol.Available for:
- Line Chart
- Multi Line Chart
- Filled Line Chart
- Ranged Line Chart
- Bar Chart
- Grouped Bar Chart
- Stacked Bar Chart
- Ranged Bar Chart
Unavailable for:
- Pie Chart
Doughnut Chart
Declaration
Swift
public func xAxisGrid<T>(chartData: T) -> some View where T : CTLineBarChartDataProtocolParameters
chartDataChart data model.
Return Value
A new view containing the chart with vertical lines under it.
-
Labels for the X axis.
The labels can either come from ChartData –> xAxisLabels or ChartData –> DataSets –> DataPoints
Requires
Chart Data to conform to CTLineBarChartDataProtocol.
Requires
Chart Data to conform to CTLineBarChartDataProtocol.
Available for:
- Line Chart
- Multi Line Chart
- Filled Line Chart
- Ranged Line Chart
- Bar Chart
- Grouped Bar Chart
- Stacked Bar Chart
- Ranged Bar Chart
Unavailable for:
- Pie Chart
Doughnut Chart
Declaration
Swift
public func xAxisLabels<T>(chartData: T) -> some View where T : CTLineBarChartDataProtocolParameters
chartDataChart data model.
Return Value
A new view containing the chart with labels marking the x axis.
-
xAxisPOI(chartData:markerName: markerValue: dataPointCount: lineColour: labelBorderColor: strokeStyle: labelPosition: labelFont: labelColour: labelBackground: customLabelShape: padding: addToLegends: ) Vertical line marking a custom value.
Shows a marker line at a specified value.
Requires
Chart Data to conform to CTLineBarChartDataProtocol.
Available for:
- Line Chart
- Multi Line Chart
- Filled Line Chart
- Ranged Line Chart
- Bar Chart
- Grouped Bar Chart
- Stacked Bar Chart
- Ranged Bar Chart
Unavailable for:
- Pie Chart
Doughnut Chart
Declaration
Swift
public func xAxisPOI<T:CTLineBarChartDataProtocol & GetDataProtocol & PointOfInterestProtocol>( chartData: T, markerName: String, markerValue: Int, dataPointCount: Int, lineColour: Color = Color(.blue), labelBorderColor: Color? = nil, strokeStyle: StrokeStyle = StrokeStyle(lineWidth: 2, lineCap: .round, lineJoin: .round, miterLimit: 10, dash: [CGFloat](), dashPhase: 0), labelPosition: DisplayValue = .center(specifier: "%.0f"), labelFont: Font = .caption, labelColour: Color = Color.primary, labelBackground: Color = Color.systemsBackground, customLabelShape: CustomLabelShape? = nil, padding: CGFloat? = nil, addToLegends: Bool = true ) -> some ViewParameters
chartDataChart data model.
markerNameTitle of marker, for the legend.
markerValueValue to mark.
dataPointCountTotal number of data points in data set.
labelPositionOption to display the markers’ value inline with the marker.
labelFontFont for the label.
labelColourColour of the
Text.labelBackgroundColour of the background.
lineColourLine Colour.
labelBorderColorCustom Color for the label border, if not provided lineColor will be used.
strokeStyleStyle of Stroke.
customLabelShapeCustom Shape for POI Label.
paddingCustom Padding between Shape and
Text.addToLegendsWhether or not to add this to the legends.
Return Value
A new view containing the chart with a marker line at a specified value.
-
Adds horizontal lines along the X axis.
The style is set in ChartData –> LineChartStyle –> yAxisGridStyle
Requires
Chart Data to conform to CTLineBarChartDataProtocol.Available for:
- Line Chart
- Multi Line Chart
- Filled Line Chart
- Ranged Line Chart
- Bar Chart
- Grouped Bar Chart
- Stacked Bar Chart
- Ranged Bar Chart
Unavailable for:
- Pie Chart
Doughnut Chart
Declaration
Swift
public func yAxisGrid<T>(chartData: T) -> some View where T : CTLineBarChartDataProtocolParameters
chartDataChart data model.
Return Value
A new view containing the chart with horizontal lines under it.
-
Automatically generated labels for the Y axis.
Controls are in ChartData –> ChartStyle
Requires
Chart Data to conform to CTLineBarChartDataProtocol.Available for:
- Line Chart
- Multi Line Chart
- Filled Line Chart
- Ranged Line Chart
- Bar Chart
- Grouped Bar Chart
- Stacked Bar Chart
- Ranged Bar Chart
Unavailable for:
- Pie Chart
Doughnut Chart
Declaration
Swift
public func yAxisLabels<T: CTLineBarChartDataProtocol>( chartData: T, specifier: String = "%.0f", formatter: NumberFormatter? = nil, colourIndicator: AxisColour = .none ) -> some ViewParameters
chartDataData that conforms to CTLineBarChartDataProtocol
specifierDecimal precision specifier
Return Value
HStack of labels
-
yAxisPOI(chartData:markerName: markerValue: labelPosition: labelFont: labelColour: labelBackground: lineColour: labelBorderColor: strokeStyle: customLabelShape: padding: addToLegends: ) Horizontal line marking a custom value.
Shows a marker line at a specified value.
Example
.yAxisPOI(chartData: data, markerName: "Marker", markerValue: 110, labelPosition: .center(specifier: "%.0f"), labelColour: Color.white, labelBackground: Color.red, lineColour: .blue, strokeStyle: StrokeStyle(lineWidth: 2, lineCap: .round, lineJoin: .round, miterLimit: 10, dash: [8], dashPhase: 0))Requires
Chart Data to conform to CTLineBarChartDataProtocol.
Available for:
- Line Chart
- Multi Line Chart
- Filled Line Chart
- Ranged Line Chart
- Bar Chart
- Grouped Bar Chart
- Stacked Bar Chart
- Ranged Bar Chart
Unavailable for:
- Pie Chart
Doughnut Chart
Declaration
Swift
public func yAxisPOI<T:CTLineBarChartDataProtocol & GetDataProtocol & PointOfInterestProtocol>( chartData: T, markerName: String, markerValue: Double, labelPosition: DisplayValue = .center(specifier: "%.0f"), labelFont: Font = .caption, labelColour: Color = Color.primary, labelBackground: Color = Color.systemsBackground, lineColour: Color = Color(.blue), labelBorderColor: Color? = nil, strokeStyle: StrokeStyle = StrokeStyle(lineWidth: 2, lineCap: .round, lineJoin: .round, miterLimit: 10, dash: [CGFloat](), dashPhase: 0), customLabelShape: CustomLabelShape? = nil, padding: CGFloat? = nil, addToLegends: Bool = true ) -> some ViewParameters
chartDataChart data model.
markerNameTitle of marker, for the legend.
markerValueValue to mark
labelPositionOption to display the markers’ value inline with the marker.
labelFontFont for the label.
labelColourColour of the
Text.labelBackgroundColour of the background.
lineColourLine Colour.
labelBorderColorCustom Color for the label border, if not provided
lineColorwill be used.strokeStyleStyle of Stroke.
customLabelShapeCustom Shape for POI Label.
paddingCustom Padding between Shape and
Text.addToLegendsWhether or not to add this to the legends.
Return Value
A new view containing the chart with a marker line at a specified value.
-
averageLine(chartData:markerName: labelPosition: labelFont: labelColour: labelBackground: lineColour: labelBorderColor: strokeStyle: customLabelShape: padding: addToLegends: ) Horizontal line marking the average.
Shows a marker line at the average of all the data points within the relevant data set(s).
Example
.averageLine(chartData: data, markerName: "Average", labelPosition: .center(specifier: "%.0f"), labelColour: Color.white, labelBackground: Color.red, lineColour: .primary, strokeStyle: StrokeStyle(lineWidth: 2, lineCap: .round, lineJoin: .round, miterLimit: 10, dash: [8], dashPhase: 0))Requires
Chart Data to conform to CTLineBarChartDataProtocol.
Available for:
- Line Chart
- Multi Line Chart
- Filled Line Chart
- Ranged Line Chart
- Bar Chart
- Grouped Bar Chart
- Stacked Bar Chart
- Ranged Bar Chart
Unavailable for:
- Pie Chart
Doughnut Chart
Declaration
Swift
public func averageLine<T:CTLineBarChartDataProtocol & GetDataProtocol & PointOfInterestProtocol>( chartData: T, markerName: String = "Average", labelPosition: DisplayValue = .yAxis(specifier: "%.0f"), labelFont: Font = .caption, labelColour: Color = Color.primary, labelBackground: Color = Color.systemsBackground, lineColour: Color = Color.primary, labelBorderColor: Color? = nil, strokeStyle: StrokeStyle = StrokeStyle(lineWidth: 2, lineCap: .round, lineJoin: .round, miterLimit: 10, dash: [CGFloat](), dashPhase: 0), customLabelShape: CustomLabelShape? = nil, padding: CGFloat? = nil, addToLegends: Bool = true ) -> some ViewParameters
chartDataChart data model.
markerNameTitle of marker, for the legend.
labelPositionOption to display the markers’ value inline with the marker.
labelFontFont for the label.
labelColourColour of the
Text.labelBackgroundColour of the background.
lineColourLine Colour.
labelBorderColorCustom Color for the label border, if not provided lineColor will be used.
strokeStyleStyle of Stroke.
customLabelShapeCustom Shape for POI Label.
paddingCustom Padding between Shape and
Text.addToLegendsWhether or not to add this to the legends.
Return Value
A new view containing the chart with a marker line at the average.