我正在尝试在 x 轴上带有日期时间的多系列 Anychart 折线图。无法完美呈现图表。它用给定的数据绘制系列 1,然后对于第二个系列,它在第一个系列值之后在 x 轴上重新渲染日期时间,然后绘制系列 2。
数据是这样的:
"data": [
{"x": "10/2/2016 01:00:00 AM", "value": "128.14"},
{"x": "10/2/2016 01:10:00 AM", "value": "112.61"}
]
},{
// second series data
"data": [
{"x": "10/2/2016 01:01:00 AM", "value": "90.54"},
{"x": "10/2/2016 01:02:00 AM", "value": "104.19"},
{"x": "10/2/2016 01:11:00 AM", "value": "150.67"}
]
它必须在 x 轴上绘制,如 10/2/2016 01:00:00 AM、10/2/2016 01:01:00 AM、10/2/2016 01:02:00 AM、10/2/2016 01 :10:00 AM, 10/2/2016 01:11:00 AM
但它的绘图类似于 10/2/2016 01:00:00 AM、10/2/2016 01:10:00 AM、10/2/2016 01:01:00 AM、10/2/2016 01:02:00上午,2016 年 10 月 2 日上午 1:11:00
更新代码:
anychart.onDocumentReady(function() {
// JSON data
var json = {
// chart settings
"chart": {
// chart type
"type": "line",
// chart title
"title": "Axes settings from JSON",
// series settings
"series": [{
// first series data
"data": [
{"x": "10/2/2016 01:00:00 AM", "value": 128.14},
{"x": "10/2/2016 01:10:00 AM", "value": 112.61},
{"x": "10/3/2016 01:00:00 AM", "value": 12.14},
{"x": "10/3/2016 01:10:00 AM", "value": 152.61},
]},{
"data": [
{"x": "10/2/2016 01:09:00 AM", "value": 28.14},
{"x": "10/2/2016 01:11:00 AM", "value": 12.61},
{"x": "10/3/2016 01:01:00 AM", "value": 1.14},
{"x": "10/3/2016 01:12:00 AM", "value": 15.61},
]
}],
// x scale settings
"xScale": {
ticks:
{scale: "DateTime"}
},
xAxes: [{
title: "Basic X Axis"
}],
// chart container
"container": "container"
}
};
// get JSON data
var chart = anychart.fromJson(json);
// draw chart
chart.draw();
});