Jawbone / JBChartView

iOS-based charting library for both line and bar graphs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JBLineChartDotsView reloadData performance issues

juliantejera opened this issue · comments

I'm displaying a lot of data in a line chart (around 2080) per line (8). And I noticed that when I enabled the the dots with the delegate method below, it took around 12 seconds to draw the line chart.

func lineChartView(lineChartView: JBLineChartView!, showsDotsForLineAtLineIndex lineIndex: UInt) -> Bool {
   return true
}

I ran the profiler and found the culprit. JBLineChartDotsView reloadData has many for loops through all dots and the entire data set, it needs to be refactored.

I'm using a NSFetchedResultsController and it's very fast without the dots.

Why would you want 2000+ dots on a screen with a resolution well under that? Just curious.

My app is displaying the prices of different fuels going back to 2008. I modified the demo app so users can be able to scroll through the line and see the price and date of each one of those fuels. It's also very nice to see the trends, even if it doesn't look amazingly well it allows users the possibility to drill down to the data they want. But yeah, the dots arent really noticeable when you have that many items.

The nature of charting is to display all available information, unlike tables which can cache rows that are offscreen. For the time being (ie. JBChartView 2.X.X), we won't be able to support a series of data points that exceed the actual resolution of the device.

The same problems occur on MKMapView when we decide to show 2000 + pins within a certain geographic area. It's why Apple recommends clustering to avoid performance issues.

We recommend that you modify your dataSource to supply a subset of points - perhaps 'clustering' those that are close to one another. You could even color the 'clusters' a different color (ie. supply a different colored dot view) and have a tooltip display the consolidated information.

I've updated the README so future developers are aware of these limitations.