General performance issues with full screen charts and multiple charts
- Dominant language
- Swift
- Stars
- 28k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
I'm currenly working on an app, where I've noticed some significant performance drops when using charts.
I have 2 scenarios where I would expect Charts to perform better.
**1. Multiple charts in a collection view:**
I have a set of charts displayed in a collection view. These charts are aligned, which means, that when you highlight a chart on a specific date, the other charts are notified and a highlight is set as well for the corresponding timestamp.
This works like a charm. However highlighting a chart isn't cheap in regards to performance, since the highlightValue function triggers a "setNeedsDisplay()" on all charts. Is there a reason why the highlight part isn't drawn on the chart as a seperate layer? Or is there some other way to highlight the chart without triggering a full redraw?
**2. Full screen highlighting**
The performance is also very poor when displaying a chart in full screen and dragging the marker around. I guess it's also because of the need to redraw the entire chart with every new highlight?
I've tested this on the latest generation of iPad Pro. So I have a very powerfull device at hand, so this shouldn't be a factor.
I've done quite a bit of testing with the profiling tool and eliminated all costly calculations like dateformatting and other calculations that is being done on my side. I've taking a screenshot from the profiling tool showing the issue.
CPU usage when dragging marker back and forth rapidly:

The heaviest stack trace:

I hope there's a simple answer to my issue and hope you guys can guide me in the right direction. :)
## Charts Environment
**Charts version/Branch/Commit Number: 3.1.1**
**Xcode version: Xcode 10.2.1**
**Swift version: 4.2**
**Platform(s) running Charts: iOS**
**macOS version running Xcode: 10.14.4**
Contributor guide
Research direction
Reproduce the two reported scenarios on iOS with Charts 3.1.1: multiple highlighted charts in a collection view and a full-screen chart while dragging the marker. Start with the supplied profiler screenshots and examine the highlightValue() and setNeedsDisplay() path; done means identifying the redraw bottleneck and an actionable performance improvement or documented limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev, performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100