Charts icon indicating copy to clipboard operation
Charts copied to clipboard

General performance issues with full screen charts and multiple charts

Open siltrifork opened this issue 6 years ago • 1 comments

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: Screenshot 2019-05-13 at 14 36 38

The heaviest stack trace: Screenshot 2019-05-13 at 14 34 51

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

siltrifork avatar May 13 '19 12:05 siltrifork

There is no good answer. That is just how it was designed at the beginning using drawRect for the whole rendering.

pmairoldi avatar May 25 '22 16:05 pmairoldi