highcharts 中的柱形图问题?

需要创建一个柱形图, xAxis是以时间戳位划分的,
代码如下:

let test_data = [];  
let data = [15.5, 13, 18, 14, 15, 19, 18];  
let currentTime = moment().format('YYYY/MM/DD HH') + ':0:0';  
for (let i = 0; i < 7; i++) {  
  let timestamp = moment(currentTime).subtract(i, 'days').format('X') * 1000;  
  let newItem = [timestamp, data[i]];  
  test_data.push(newItem);  
}  
  
setTimeout(function () {  
  console.log(test_data);  
  Highcharts.chart('container', {  
    chart: {  
      type: 'column'  
  },  
  time: {  
      useUTC: false  
  },  
  xAxis: {  
   type: 'datetime',  
   lineWidth: 1,  lineColor: '#8E8E8E',  
   labels: {  
     align: 'center',  
     style: {  
       color: '#000000'  
     }  
   },  
   dateTimeLabelFormats: {  
     second: '%H:%M:%S',  
     minute: '%H:%M',  
     hour: '%H:%M',  
     day: '%m-%d',  
     week: '%Y%m-%d',  
     month: '%Y-%m',  
     year: '%Y'  
   }  
},  
yAxis: {  
  min: 0,  
  title: {  
    text: 'Rainfall (mm)'  
  }  
},  
plotOptions: {  
  column: {  
    pointPadding: 0.2,  
    borderWidth: 0  
  }  
},  
series: [{  
  showInLegend: false,  
  pointRange: 0,  
  color: '#FE8C00',  
  data: test_data  
  }]  
});  
}, 10);

但是结果显示为:
image.png

日期与数据不能对齐, highchart 的版本是7.2.0, 求大佬赐教

阅读 930
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题