SwiftUICharts

2.0.0

ChartView made in SwiftUI
AppPear/ChartView

What's New

2.0.0

2026-03-02T08:35:17Z

Changelog

2.0.0

Added

  • Full SwiftUI-idiomatic modifier API:
    • chartData, chartXRange, chartYRange
    • chartGridLines, chartGridStroke, chartGridBaseline
    • chartXAxisLabels, chartYAxisLabels, chartAxisFont, chartAxisColor
    • chartLineWidth, chartLineBackground, chartLineMarks, chartLineStyle, chartLineAnimation
    • chartInteractionValue
    • chartSelectionHandler
    • chartPerformance
  • Immutable chart configuration structs and environment-key-based composition.
  • Updated docs/examples and generated showcase app.
  • Dynamic streaming data source support via ChartStreamingDataSource.
  • Unified X-axis alignment strategy shared across chart layers.
  • Apple privacy manifest for SDK distribution (PrivacyInfo.xcprivacy).

Changed

  • Major clean break from mutating chain APIs.
  • Chart style/data/range/axis/grid/line configs are now modifier-driven and value-based.

Fixed

  • Removed required @EnvironmentObject interaction dependency for basic chart rendering paths.
  • Existing regression and smoke tests remain green after API shift.

Migration

  • See MIGRATION.md for full old-to-new mapping.

SwiftUICharts

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.

Charts

  • LineChart
  • BarChart
  • PieChart
  • RingsChart

Installation

Use Swift Package Manager in Xcode and add:

https://github.com/AppPear/ChartView

Migration

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

Quick Start

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)

Full Examples

See example.md and Examples/SwiftUIChartsShowcase for complete showcase code.

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Wed Apr 01 2026 23:08:29 GMT-0900 (Hawaii-Aleutian Daylight Time)