LineChart supports built-in downsampling through chartPerformance(_:).
public enum ChartPerformanceMode {
case none
case automatic(threshold: Int, maxPoints: Int, simplifyLineStyle: Bool)
case downsample(maxPoints: Int, simplifyLineStyle: Bool)
}LineChart()
.chartData(largeSeries) // e.g. 2000+ points
.chartPerformance(.automatic(
threshold: 600,
maxPoints: 180,
simplifyLineStyle: true
))When simplifyLineStyle is enabled:
- line style switches to straight
- chart marks are disabled
- line animation is disabled
This reduces render overhead for dense data.
For chartData([Double]), downsampled values are remapped to categorical slot indices to keep axis alignment stable.
- Compare visual shape with and without downsampling.
- Ensure tooltips/selection still target expected points.
- Tune
thresholdandmaxPointsfor your dataset size and UI refresh rate.