Let's get straight to the point: I started to use iOS Charts by Daniel Gindi, but I just can't reproduce this wavy lines in my line chart
(and please notice that this image is picked form the repository of iOS charts!)
All I get is just this, simple straight lines with no curves
And this is the code in viewDidLoad that I used for showing that:
let ys1 = Array(1..<10).map { x in return sin(Double(x) / 2.0 / 3.141 * 1.5) }
let ys2 = Array(1..<10).map { x in return cos(Double(x) / 2.0 / 3.141) }
let yse1 = ys1.enumerated().map { x, y in return ChartDataEntry(x: Double(x), y: y) }
let yse2 = ys2.enumerated().map { x, y in return ChartDataEntry(x: Double(x), y: y) }
let data = LineChartData()
let ds1 = LineChartDataSet(values: yse1, label: "Hello")
ds1.colors = [NSUIColor.red]
ds1.drawCirclesEnabled = false
ds1.drawValuesEnabled = false
data.addDataSet(ds1)
let ds2 = LineChartDataSet(values: yse2, label: "World")
ds2.colors = [NSUIColor.blue]
ds2.drawCirclesEnabled = false
ds2.drawValuesEnabled = false
data.addDataSet(ds2)
self.viewChart.data = data
self.viewChart.gridBackgroundColor = NSUIColor.white
self.viewChart.chartDescription?.text = "Linechart Demo"
Can someone help me? Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…