Description
What did you do?
Create a simple line chart with .horizontalBezier mode enabled.
What did you expect to happen?
As usual: draw a chart.
What happened instead?
With, for example, 2000 values it takes about one minute to render this chart. On Android (using MPAndroidChart) it can even handle more than 10000 values easily. Removing set.mode = .horizontalBezier helps, but it I think this is a real issue as 2000 values aren't that much. Just a funny note: it the real app user had 30000 values on his chart (actually there are 3 charts 30000 values each). I tested on his account and it took 90 minutes (!) to render this chart. From the other hand on Android, it took about a 2 minutes. I know 30000 is just too much so I'll try to reduce the number of values, but still, 2000 taking so much time is really bad. That forces me to disable .horizontalBezier when there are more than 1000 values.
Charts Environment
Charts version/Branch/Commit Number: 3.1.1 Xcode version: 9.4.1 Swift version: 4.1 Platform(s) running Charts: iOS 11.4 (tried on iPhone 6 and on iPad Pro 10.5') macOS version running Xcode: 10.13.5
Demo Project
This is a demo project with modified LineChart1ViewController.swift file. Just run the app and tap the first option (Line Chart). My project is much more complex so I've created this simple demo as removed as much code as possible.
Just in case I'm also putting here source code directly:
import UIKit
import Charts
class LineChart1ViewController: DemoBaseViewController {
@IBOutlet var chartView: LineChartView!
@IBOutlet var sliderX: UISlider!
@IBOutlet var sliderY: UISlider!
@IBOutlet var sliderTextX: UITextField!
@IBOutlet var sliderTextY: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
self.options = []
self.setDataCount(2000, range: 100)
}
func setDataCount(_ count: Int, range: UInt32) {
let values = (0..<count).map { (i) -> ChartDataEntry in
let val = Double(arc4random_uniform(range) + 3)
return ChartDataEntry(x: Double(i), y: val)
}
let set = LineChartDataSet(values: values, label: "DataSet 1")
set.mode = .horizontalBezier
let data = LineChartData(dataSet: set)
chartView.data = data
}
override func optionTapped(_ option: Option) {}
@IBAction func slidersValueChanged(_ sender: Any?) {}
}