简体   繁体   English

高图样条线未显示

[英]Highcharts Spline lines not showing up

I am trying to plot a spline graph with the following data: 我正在尝试使用以下数据绘制样条图:

[
    {
        "name": "Version 1.0",
        "data": [
            "10/9/2014, 11:47:03 AM",
            170.023
        ]
    },
    {
        "name": "Version 1.1",
        "data": [
            "10/8/2014, 1:00:00 AM",
            1967.02,
            [
                "10/9/2014, 11:00:19 AM",
                167.023
            ],
            [
                "10/9/2014, 9:34:49 PM",
                1974.03
            ],
            [
                "10/9/2014, 9:45:33 PM",
                1983.02
            ],
            [
                "10/9/2014, 10:36:10 PM",
                1989.03
            ],
            [
                "10/10/2014, 3:05:37 AM",
                1972.02
            ],
            [
                "10/10/2014, 5:01:43 AM",
                1980.02
            ],
            [
                "10/10/2014, 8:37:18 AM",
                16.0215
            ],
            [
                "10/10/2014, 2:37:44 PM",
                1994.02
            ]
        ]
    }
]

Here is a JSFiddle of it: http://jsfiddle.net/rknLa2sa/3/ 这是其中的一个JSFiddle: http : //jsfiddle.net/rknLa2sa/3/

The points are correctly plotted but they are not connected with a line. 点已正确绘制,但未与线连接。 How do I make these points be connected on the graph? 如何使这些点在图形上连接? Also how do I make the dates I have in the data array show up on the x-axis as well as the tool-tip. 另外,如何使数据数组中的日期显示在x轴以及工具提示上。

You have forgotten some brackets in your data around 您忘记了数据中的一些括号

"10/8/2014, 1:00:00 AM",
            1967.02,

http://jsfiddle.net/rknLa2sa/4/ http://jsfiddle.net/rknLa2sa/4/

In order to show label you could preprocess your data and convert the dates to UTC format 为了显示标签,您可以预处理数据并将日期转换为UTC格式

like this 像这样

 [
   Date.UTC(2014, 8, 10, 10),
   167.023
 ],

http://jsfiddle.net/rknLa2sa/7/ http://jsfiddle.net/rknLa2sa/7/

Instead of using Date.UTC() you can map your points using new Date(..).getTime() . 可以使用new Date(..).getTime()代替使用Date.UTC()来映射点。 Example: http://jsfiddle.net/rknLa2sa/10/ 示例: http//jsfiddle.net/rknLa2sa/10/

        data: [
            ["10/8/2014, 1:00:00 AM", 1967.02],
            ["10/9/2014, 11:00:19 AM", 167.023],
            ["10/9/2014, 9:34:49 PM", 1974.03],
            ["10/9/2014, 9:45:33 PM", 1983.02],
            ["10/9/2014, 10:36:10 PM", 1989.03],
            ["10/10/2014, 3:05:37 AM", 1972.02],
            ["10/10/2014, 5:01:43 AM", 1980.02],
            ["10/10/2014, 8:37:18 AM", 16.0215],
            ["10/10/2014, 2:37:44 PM", 1994.02]
        ].map(function (e) {
            return [new Date(e[0]).getTime(), e[1]];
        })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM