gpt4 book ai didi

ios - SciChart iOS 日期折线图

转载 作者:可可西里 更新时间:2023-11-01 01:16:25 34 4
gpt4 key购买 nike

我在将日期附加到我的 SciChart 折线图时遇到问题。我在运行时遇到此错误。

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Axis does not support type.'

我按照提供的示例进行操作,这是我将数据附加到轴的代码。

var sciChartSurface: SCIChartSurface?

var lineDataSeries: SCIXyDataSeries!

var lineRenderableSeries: SCIFastLineRenderableSeries!

func createDataSeries(){

lineDataSeries = SCIXyDataSeries(xType: .dateTime, yType: .double)

lineDataSeries.acceptUnsortedData = true

let items = self.dataFeed.priceHistory

let dateFormatter = DateFormatter()

dateFormatter.dateFormat = "yyyy-MM-dd"

for i in 0..<(items.count) - 1 {

let date:Date = dateFormatter.date(from: items[i].date!)!
print("\(date) \(items[i].close!)")
lineDataSeries.appendX(SCIGeneric(date), y: SCIGeneric(Double(items[i].close!)))
}
}

这是我打印语句的输出

2017-08-09 07:00:00 +0000 2474.02
2017-08-08 07:00:00 +0000 2474.92
2017-08-07 07:00:00 +0000 2480.91
2017-08-04 07:00:00 +0000 2476.83
2017-08-03 07:00:00 +0000 2472.16
2017-08-02 07:00:00 +0000 2477.57

知道我做错了什么吗?如果需要,很高兴包含整个 ViewController。

最佳答案

错误在于我如何设置 axix,它必须设置为 datetimeaxis....

func setUpUI() {
// Create a SCIChartSurface. This is a UIView so can be added directly to the UI
sciChartSurface = SCIChartSurface(frame: self.view.bounds)
sciChartSurface?.translatesAutoresizingMaskIntoConstraints = true

// Add the SCIChartSurface as a subview
self.view.addSubview(sciChartSurface!)

// Create an XAxis and YAxis. This step is mandatory before creating series
sciChartSurface?.xAxes.add(SCIDateTimeAxis())
sciChartSurface?.yAxes.add(SCINumericAxis())
}

关于ios - SciChart iOS 日期折线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46203985/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com