我正在尝试使用以下数据绘制样条图:
[
{
"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
]
]
}
]
这是一个JSFiddle:http://jsfiddle.net/rknLa2sa/3/
正确绘制了点,但它们未与线连接。如何在图表上连接这些点? 另外,如何使数据数组中的日期显示在x轴和工具提示上。
答案 0 :(得分:2)
您忘记了数据中的一些括号
"10/8/2014, 1:00:00 AM",
1967.02,
http://jsfiddle.net/rknLa2sa/4/
为了显示标签,您可以预处理数据并将日期转换为UTC格式
像这样 [
Date.UTC(2014, 8, 10, 10),
167.023
],
答案 1 :(得分:1)
您可以使用Date.UTC()
映射您的积分,而不是使用new Date(..).getTime()
。示例: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]];
})