ChartsOrg / ChartsOrg/Charts

Slow zoom & pan performance for line charts with over ~1k points onscreen

Open
#2,300 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

I'm using a LineChartView with a single dataset containing about 4k points. Zoomed in, it is performant. When I zoom out substantially, it grinds to a halt. In profiler, it appears that most time is being spent on context.strokePath() in drawLinear(context:dataset) of LineChartRenderer.swift.

I attempted the same thing in the Demo project using LineChart1ViewController. I changed the X slider to be 4k and noticed zooming and panning effectively ground to a halt when set above 1k points when zoomed all the way out. Zoomed in, it was of course fine. This was with the default 'filled' option being turned off in the popup.

I'm trying to figure out if there are any options I can toggle to improve performance. I don't have much turned on right now - certainly no shading or gradients. What else is especially time consuming to draw?

The Android Wiki had mentioned this should be able to support charts up to about 10k points, so I can't help but wonder if what I'm doing is possible with the right configuration.

Contributor guide

Open the contributing guide

Research direction

Start with LineChartRenderer.swift, especially drawLinear(context:dataset), and reproduce the slowdown through the Demo project's LineChart1ViewController with about 4k points. Profile zooming and panning above 1k points with the default filled option disabled, then verify that the identified rendering path no longer makes zooming and panning grind to a halt.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
mobile-dev, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.