SciChart iOS日期在折线图上

时间:2017-09-13 17:54:51

标签: ios swift charts scichart

我无法将日期附加到我的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!)))
    }
}

这是我从print语句输出的内容

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。

1 个答案:

答案 0 :(得分:2)

错误在于我如何设置axix并且必须将其设置为datetimeaxis ....

from tkinter import *
import quotes              #Imported external module having quotations
my_quote = "Random quote."

root = None
textSpace = None
texter = None

def textBox(parent):        #creates a text box
    global textSpace
    textSpace = Entry(parent)
    textSpace.place(x = 205, y = 190, width = "200")

def text_input():
    global texter
    texter = textSpace.get()
    print("Text entered:", texter)

def quotes():               #Random quote at bottom of window
    global root
    quote_text = Label(root, text = my_quote, font = ("papyrus", 7, 
    "italic"), 
    bg = "light sky blue")
    quote_text.pack(side = "bottom")

def main_win():             #This is the main window
    global root
    global textSpace
    input = textBox         #I am not sure if this is correct
    user_command = input
    root = Tk()             #We have to initiate the window right
    root.title("Greetings")
    root.configure(bg = "light sky blue")
    root.geometry("600x350")
    head_text = Label(root, text = "PEWDS", font=("Comic Sans MS", 36, 
    "bold"), bg = "light sky blue", fg = "purple")
    head_text.pack(side = "top")
    sub_text = Label(root, text = "Enter your command below.", font=("MS 
    sans serif", 20, "italic"), bg = "light sky blue", fg = "alice blue")
    sub_text.pack()
    quotes()
    go_button = Button(text = "GO", command = text_input)
    go_button.place(x=285, y=230)
    go_button.configure(bg = "cadetblue")
    textBox(root)
    root.mainloop


main_win()