需要创建一个柱形图, 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);
但是结果显示为:
日期与数据不能对齐, highchart 的版本是7.2.0, 求大佬赐教