I'm using the Swift version of the 'Charts' framework in iOS ( https://github.com/danielgindi/Charts ) to chart a series of lines. If I chart any one of the lines, it works fine.
But if I attempt to chart all of the lines, only the last line appears on the chart correctly, and the other lines display only their first chart point each. (See image below.)
Here's my code:
func refreshChart() {
var chartDataSets: [LineChartDataSet] = []
var xDistance = 0.0
for lineIndex in 0..<4 {
var chartEntries: [ChartDataEntry] = [] // New set of chart entries for each line
var yElevation = Double(lineIndex)
for _ in 0..<10 {
xDistance += 1.0
yElevation += 1.0
logger.log("\(lineIndex): \(xDistance), \(yElevation)")
chartEntries.append(ChartDataEntry(x: xDistance, y: yElevation))
}
chartDataSets.append(LineChartDataSet(entries: chartEntries, label: "Elevation"))
}
let chartData = LineChartData(dataSets: chartDataSets)
lineChartView.data = chartData
for dataSet in chartData {
for i in 0..<dataSet.entryCount {
if let entry = dataSet.entryForIndex(i) {
print("\(i): \(entry.x), \(entry.y)")
}
}
}
}
The diagnostic output at the end displays all the X, Y values that I would expect for each of the 4 lines. They just don't appear on the chart!
What am I doing wrong here?