1
HighChart时间序列小时,我这里有一个小提琴:开始于下午4点
http://jsfiddle.net/sawaira/944zsyy5/2/
$(function() {
console.log([new Date(2010, 0, 1, 0, 0, 0), 1],
[new Date(2010, 0, 1, 1, 0, 0), 2],
[new Date(2010, 0, 1, 2, 0, 0), 3],
[new Date(2010, 0, 1, 3, 0, 0), 4]);
Highcharts.setOptions({ // This is for all plots, change Date axis to local timezone
global : {
useUTC : false
}
});
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
zoomType: 'xy'
},
xAxis: {
type: 'datetime',
labels: {
formatter: function() {
// Show hour and am/pm
console.log(this.value);
return Highcharts.dateFormat("%l %p", this.value);
},
},
},
series: [{
data: [
[new Date(2010, 0, 1, 0, 0, 0), 1],
[new Date(2010, 0, 1, 1, 0, 0), 2],
[new Date(2010, 0, 1, 2, 0, 0), 3],
[new Date(2010, 0, 1, 3, 0, 0), 4]
]
}]
});
});
当使用HighChart选项呈现在X轴次,我总是得到结果,从下午4点。请注意,useUTC
是错误的,并且我添加了一堆console.log()
以查看时间值是否与预期的一样,并且它们是。
为什么我得到上面描述的结果?
看来,将值更改为.getTime()使其工作。 – Programmer