我几乎完成了我的高图,但我无法让日期时间/时间戳看起来正确。我不确定它是xAxis的格式,还是它的格式。
我的数据:
[{"x":"2016-04-08 12:11:02","y":32},{"x":"2016-04-08 14:22:07","y":2},{"x":"2016-04-11 10:10:06","y":4},{"x":"2016-04-11 11:56:35","y":2},{"x":"2016-04-11 12:16:20","y":2},{"x":"2016-04-11 14:09:27","y":2},{"x":"2016-04-11 15:03:31","y":1},{"x":"2016-04-11 20:18:41","y":1172},{"x":"2016-04-11 21:00:06","y":1014}]
$('#container').highcharts('StockChart', {
rangeSelector : {
selected : 1
},
xAxis: {
type: 'datetime'
},
title : {
text : 'test'
},
series : [{
name : 'signups',
data : data,
turboThreshold : 0
}]
});
我确定这是我遗漏的一件小事。感谢
答案 0 :(得分:1)
对于您的每个日期,请将其转换为Date.UTC
var date = new Date(yourData[i].x);
var year = date.getFullYear();
var month = date.getMonth();
var day = date.getDate();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
console.log(new Date(Date.UTC(year, month, day, hours, minutes, seconds)));
然后将其插入您的系列 可能很长但是,它会起作用。 看看这个FIDDLE: