我正在构建热图图表的中间,但是我在我的json文件中从时间戳数据在Y轴添加日期时间时出现问题,它在我的Y轴图表中只显示00:00:00:001。 / p>
这是我的代码
$(document).ready(function() {
var options = {
chart: {
renderTo: 'container',
type: 'heatmap'
},
xAxis: {
tickPixelInterval: 1000,
categories: []
},
yAxis: {
type: 'datetime'
},
legend: {
align: 'right',
layout: 'vertical',
margin: 0,
verticalAlign: 'top',
symbolHeight: 280
},
colorAxis: {
stops: [
[0, '#3060cf'],
[0.5, '#fffbbc'],
[0.9, '#c4463a']
],
min: -5
},
plotOptions: {
series: {
turboThreshold: 0
}
},
series: [{
dataLabels: {
enabled: true,
color: '#000000'
}
}]
};
var ajaxCounter = 0,
dataArr = [],
intervalId = setInterval(function() {
$.getJSON('test.json', function(data) {
var categories = [],
prevCat = -1,
numb = -1;
Highcharts.each(data, function(xvals, i) {
if (prevCat !== xvals[0]) {
numb++;
prevCat = xvals[0];
categories.push((xvals[0]));
dataArr.push([numb, ajaxCounter, xvals[2]]);
} else {
dataArr.push([numb, ajaxCounter, xvals[2]]);
}
});
ajaxCounter++;
options.xAxis.categories = categories;
options.series[0].data = dataArr;
var chart = new Highcharts.Chart(options);
if (ajaxCounter === 24) {
clearInterval(intervalId);
}
});
}, 10000);
});
这是我的json文件
[
[100,1474633760,0],
[200,1474633760,0],
[300,1474633760,2471.0],
[400,1474633760,0],
[500,1474633760,0],
[600,1474633760,1951.0],
[700,1474633760,0],
[800,1474633760,0],
[900,1474633760,2125.0],
[1000,1474633760,0]
]
谢谢你的关注,我希望你们能帮助我的小项目