javascript - Highcharts条形图x轴不一致行为

标签 javascript highcharts

我有包含每日数据的图表,我通过在 minDate 中指定名为 minDate 和 maxDate 的范围来创建以一小时为间隔的 x 轴,指定 minDate 当天的开始时间,并在 maxDate 中指定第二天的开始时间。即用户选择 20/aug/2015,minDate 将为 20-08-2015 00:00:00:00,maxDate 将为 21-08-2015 00:00:00:00(以毫秒为单位)。

代码如下:

dateRangeFromMilli: function(startDate, noOfDays){
        var minMax = [],
            oneDayMilli = 24 * 60 * 60 * 1000,
            firstDate = new Date(startDate);
        minMax.push(firstDate.getTime());

    for(var i = 1; i < noOfDays ; i++) {
        minMax.push(firstDate.getTime() + oneDayMilli);
    }

    return minMax;
},

var $date = $("#selDate"),
        minMax = HSDateUtils.dateRangeFromMilli($date.val(), 2);

Highcharts.setOptions({
   global: {
            useUTC: false,
            timezoneOffset: new Date().getTimezoneOffset()
   }
});


xAxis: {
       title: {
               enabled: true,
               text: 'Hours'
       },
       type: 'datetime',
       tickInterval: 3600 * 1000,
       min: minMax[0],
       max: minMax[1],
       labels: {
               enabled: true,
               formatter: function (){
                        return Highcharts.dateFormat('%I %p',this.value);
               },
               style:{
                      width:'1px'
               },
               step: 1
               },
       dateTimeLabelFormats: {
               hour: '%I %p'
       },
       plotBands: {
             color: 'rgba(101, 109, 120, 0.2)', // Color value
             from: 0.5, // Start of the plot band
             to: 2.7
          }
      },

数据不一致的图像如下: enter image description here

enter image description here

enter image description here

enter image description here

请查看 jsfiddle 链接 对于图像 4: http://jsfiddle.net/oa4mo6ww/5/

对于图像3 http://jsfiddle.net/oa4mo6ww/6/

最佳答案

作为解决方法,您可以为系列设置pointRange。 示例:http://jsfiddle.net/641dpb11/1/

这是一个已经报告的错误 - https://github.com/highslide-software/highcharts.com/issues/4184

关于javascript - Highcharts条形图x轴不一致行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32135562/

相关文章:

javascript - 在 Highcharts 仪表图中,如何将 plotband 标签居中放置?

php - Highcharts 显示在某些页面中,而不显示在根页面中

javascript - 如何提高您在 HighCharts 中的表现

javascript - 在循环中单击描述时,knockout.js 不会触发单击事件

javascript - ShallowWrapper 只能包装有效元素 - Enzyme Reactjs

javascript - 如何使用 jquery 禁用表中除单击的复选框之外的行和列复选框

javascript - ES6 Module Loader中简单import语句和System.import的区别

javascript - Highcharts 未在grails View 中呈现

javascript - 具有共享和拆分工具提示的 Highcharts,是否可以设置悬停 xAxis 标签的样式?

javascript - 替换浏览器插件中的大量文本