I am pulling data from a JSON file.
Against any given date are four separate items of data that I want to display separately, on the same chart.
Taking the time series example supplied by Shinobi how do I inject the data into multiple series.Index rather than just one.
The code below, apart from being inelligent, doesn't work and I can't quite fathom the data data structure Shinobi requires to separate the data against each series.
func loadChartData() {
// Create volume and stock price data points from JSON data
for dataPoint inJSONDataFromFile("AppleData") {
guardlet
dateString = dataPoint["date"] as? String,
stockOpen = dataPoint["open"] as? NSNumber,
stockHigh = dataPoint["high"] as? NSNumber,
stockLow = dataPoint["low"] as? NSNumber,
stockClose = dataPoint["close"] as? NSNumber
else {
print("Malformed JSON data")
return
}
let date = dateFormatter.dateFromString(dateString)
let stockDataPoint = SChartDataPoint()
stockDataPoint.sChartDataPointIndex = 0
stockDataPoint.xValue = date
stockDataPoint.yValue = stockClose
stockPriceData.append(stockDataPoint)
stockDataPoint.sChartDataPointIndex = 1
stockDataPoint.xValue = date
stockDataPoint.yValue = stockOpen
stockPriceData.append(stockDataPoint)
stockDataPoint.sChartDataPointIndex = 2
stockDataPoint.xValue = date
stockDataPoint.yValue = stockHigh
stockPriceData.append(stockDataPoint)
stockDataPoint.sChartDataPointIndex = 3
stockDataPoint.xValue = date
stockDataPoint.yValue = stockLow
stockPriceData.append(stockDataPoint)
}
}