Charts
Charts copied to clipboard
LineChartView Data rendering problems
Hello! When I need to render thousands of data, the CPU is too high, causing the app to jam. How can I solve this problem
Me too!!!
Same here, even for 2000 datapoints the performance is really slow and the app freezes for a few seconds.
looking for solution around this as well. I am importing heart rate data from HealthKit, and heart rate is measured very frequently. I can get around this performance issue if i just take one data point from each day, but that doesn't reflect a true trend. Looking for any advice.
Same here for me! :)
HOW TO SOLUTION???
So in my case I used IAxisValueFormatter to replace the x-values by Strings. This caused the CPU issues, because the function reloaded the x-axis String values each time I touched the Chart.
Solution for me was to replace my old IAxisValueFormatter function by this one:
// x-Achsen Werte ersetzen final class CustomFormatter: IAxisValueFormatter { var labels: [String] = [] func stringForValue(_ value: Double, axis: AxisBase?) -> String { let count = self.labels.count guard let axis = axis, count > 0 else { return "" } let factor = axis.axisMaximum / Double(count) let index = Int((value / factor).rounded()) if index >= 0 && index < count { return self.labels[index] } return "" } }
@jungerph what was your previous implementation and why is this approach better than the one before?
@gag1995 which modes are you using for your datasets? My workaround right now is to use .linear mode where performance is good for large datasets. If you change to any bezier type, then performance is bad
The same problem, but with YAxis. Method stringForValue consume too much CPU.