2014-10-06 80 views
3

这里是我的问题,一个小提琴:http://jsfiddle.net/v0bxdqa7/5/错误对准highcharts日期时间点与x轴

正如你所看到的,点不与x轴值一致。

我从高楼网站上显示的例子中相信,问题出在我的数据上,但是我找不到确切的问题。

任何想法?

我的选择:

 rangeSelector: { 
     inputEnabled: false, 
     selected: 1, 
     buttons: [{ 
      type: 'day', 
      count: 7, 
      text: '7' 
     }, { 
      type: 'day', 
      count: 30, 
      text: '30' 
     }, { 
      type: 'year', 
      count: 1, 
      text: '365' 
     }, { 
      type: 'ytd', 
      text: 'year' 
     }] 
    }, 
    tooltip: { 
     headerFormat: '<small style="color: #666680">{point.key}</small><br>', 
     pointFormat: '<span style="color: #acacbf">{series.name}: </span>' + 
     '<span style="color: #666680"><b>{point.y}</b></span>' 
    }, 
    xAxis: { 
     lineColor: '#ebebeb', 
     type: 'datetime', 
     labels: { 
      style: { 
       color: '#acacbf' 
      }, 
      align: "center", 
      maxStaggerLines: 1, 
      overflow: false 
     } 
    }, 
    yAxis: { 
     allowDecimals: false, 
     gridLineWidth: 0, 
     labels: { 
      enabled: false, 
      style: { 
       color: '#acacbf' 
      } 
     }, 
     min: 0, 
     floor: 0, 
     minRange:1 
    }, 
    navigator: {enabled: false}, 
    chart: { 
     className: "line-chart", 
     backgroundColor: "#f7f7f7", 
     margin:[10,5,22,5] 
    }, 
    plotOptions: { 
     series: { 
      marker: { 
       enabled: true, 
       states: { 
        hover: { 
         radius: 5 
        }, 
        select: { 
         enabled: true, 
         radius: 5, 
         fillColor: '#ffffff', 
         lineColor: '#ad49a5' 
        } 
       } 
      } 
     } 
    }, 
    scrollbar: { 
     enabled: false 
    }, 
    colors: ["#ad49a5"] 
+4

所有日期时间数据点的时间部分都是'15:08',当Highcharts打出x轴时,打勾是在一天的开始,而不是3小时,下午8分钟。 – Mark 2014-10-06 18:41:06

+4

这是一个固定的小提琴:http://jsfiddle.net/v0bxdqa7/6/ – Mark 2014-10-06 18:51:20

回答

0

Indead你(时间戳)的数据是错误的。

以第一个为例:1370787037000如果您将其转换成Sun, 09 Jun 2013 14:10:37 GMT,那么这正是图表上绘制的内容。

如果您希望此点准确位于Sun, 09 Jun 2013 00:00:00 GMT那么它的正确时间戳是1370736000000。你必须为每个日期做这件事。