Working on building a candlestick chart in Swift. I have a working chart following the example. I get zoom and pan fine. But am getting an error when I swipe left on the chart. Can’t quite figure out what I’m missing. Seems like my data is unsorted but I don’t see any documentation on how it should be sorted and glad to send the repo if you like…
Thanks much – Warren
2017-09-14 14:31:39.426976-0700 GoogleStockAPI[7040:2331198] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unsorted data occurs in the collection. The only allowed SearchMode is SCIArraySearchMode_Exact'
*** First throw call stack:
(0x18a2c6fe0 0x188d28538 0x1013c9644 0x101422af0 0x1013fbdb0 0x101421b28 0x1013fb7c8 0x101398be8 0x101399084 0x10142dd04 0x1013effd0 0x1013a22dc 0x10140a47c 0x101419f04 0x1023f44fc 0x18d4d95dc 0x18d4d948c 0x18a533b9c 0x18a25d960 0x18a275ae4 0x18a275284 0x18a272d98 0x18a1a2da4 0x18bc0d074 0x19045dc9c 0x1000ceb1c 0x1891b159c)
libc++abi.dylib: terminating with uncaught exception of type NSException
I am getting my data for this chart from a live API and after I parse the JSON I populate it with this as
Date, Double, Double, Double, Double, and it looks like this –
Date OHLC: 2017-04-27 07:00:00 +0000 143.9225 144.16 143.31 143.79
Date OHLC: 2017-04-26 07:00:00 +0000 144.47 144.6 143.3762 143.68
Here is the function to render the series
fileprivate func getCandleRenderSeries(_ isReverse: Bool,
upBodyBrush: SCISolidBrushStyle,
upWickPen: SCISolidPenStyle,
downBodyBrush: SCISolidBrushStyle,
downWickPen: SCISolidPenStyle,
count: Int) -> SCIFastCandlestickRenderableSeries {
let ohlcDataSeries = SCIOhlcDataSeries(xType: .dateTime, yType: .double)
ohlcDataSeries.acceptUnsortedData = true
let items = self.dataFeed.lastPrice
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
for i in 0..<(items.count) - 1 {
let date:Date = dateFormatter.date(from: items[i].date!)!
ohlcDataSeries.appendX(SCIGeneric(date),
open: SCIGeneric(items[i].open!),
high: SCIGeneric(items[i].high!),
low: SCIGeneric(items[i].low!),
close: SCIGeneric(items[i].close!))
}
let candleRendereSeries = SCIFastCandlestickRenderableSeries()
candleRendereSeries.dataSeries = ohlcDataSeries
candleRendereSeries.fillUpBrushStyle = upBodyBrush
candleRendereSeries.fillDownBrushStyle = downBodyBrush
candleRendereSeries.strokeUpStyle = upWickPen
candleRendereSeries.strokeDownStyle = downWickPen
return candleRendereSeries
}
- Warren Hansen asked 7 years ago
-
I removed SCIRolloverModifier() and no longer get the error. I must be missing a delegate for that.
- You must login to post comments
Please login first to submit.