SwiftUICharts is an open-source chart library for SwiftUI with iOS 13 compatibility.
This release uses a fully composable, SwiftUI-idiomatic API based on immutable configuration and ViewModifier chains.
LineChartBarChartPieChartRingsChart
Use Swift Package Manager in Xcode and add:
https://github.com/AppPear/ChartView
This is a major composable API release.
- Previous chain APIs like
.data,.rangeX,.rangeY,.setAxisXLabels,.setNumberOfHorizontalLines, and line-specific setters were replaced by typed chart modifiers. - Full old-to-new mapping: MIGRATION.md
Simple line chart
LineChart()
.chartData([3, 5, 4, 1, 0, 2, 4, 1, 0, 2, 8])
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))Add background grid
ChartGrid {
LineChart()
.chartData([3, 5, 4, 1, 0, 2, 4, 1, 0, 2, 8])
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))
}
.chartGridLines(horizontal: 5, vertical: 4)Axis labels
AxisLabels {
ChartGrid {
LineChart()
.chartData([3, 5, 4, 1, 0, 2, 4, 1, 0, 2, 8])
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))
}
.chartGridLines(horizontal: 5, vertical: 4)
}
.chartXAxisLabels([(1, "Nov"), (2, "Dec"), (3, "Jan")], range: 1...3)Line config + ranges
AxisLabels {
ChartGrid {
LineChart()
.chartLineMarks(true)
.chartData([3, 5, 4, 1, 0, 2, 4, 1, 0, 2, 8])
.chartYRange(0...10)
.chartXRange(0...5)
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))
}
.chartGridLines(horizontal: 5, vertical: 4)
}
.chartXAxisLabels([(1, "Nov"), (2, "Dec"), (3, "Jan")], range: 1...3)Mix chart types
AxisLabels {
ChartGrid {
BarChart()
.chartData([2, 4, 1, 3])
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))
LineChart()
.chartLineMarks(true)
.chartData([2, 4, 1, 3])
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.blue, .purple)))
}
.chartGridLines(horizontal: 5, vertical: 4)
}
.chartXAxisLabels([(1, "Nov"), (2, "Dec"), (3, "Jan")], range: 1...3)See example.md and Examples/SwiftUIChartsShowcase for complete showcase code.







