目前我正试图找到一种方法来显示时间序列数据通过一个热图通过 highcharts ,我想知道是否有一种方法来绘制这种方式的数据,而不诉诸于使用CSV。下面的链接是我想重现的图表类型:
https://www.highcharts.com/demo/heatmap-canvas
目前这是我在这方面的尝试,通过使用数组来存储数据,但由于某种原因,数据根本没有绘制...
Highcharts.chart('container', {
data: {
//csv: document.getElementById('csv').innerHTML
},
chart: {
type: 'heatmap'
},
boost: {
useGPUTranslations: true
},
title: {
text: 'Highcharts heat map',
align: 'left',
x: 40
},
subtitle: {
text: 'Temperature variation by day and hour through 2017',
align: 'left',
x: 40
},
xAxis: {
type: 'datetime',
min: Date.UTC(2017, 0, 1),
max: Date.UTC(2017, 0, 8, 23, 59, 59),
labels: {
align: 'left',
x: 5,
y: 14,
format: '{value:%B}' // long month
},
showLastLabel: false,
tickLength: 16
},
yAxis: {
title: {
text: null
},
labels: {
format: '{value}:00'
},
minPadding: 0,
maxPadding: 0,
startOnTick: false,
endOnTick: false,
tickPositions: [0, 6, 12, 18, 24],
tickWidth: 1,
min: 0,
max: 23,
reversed: true
},
colorAxis: {
stops: [
[0, '#3060cf'],
[0.5, '#fffbbc'],
[0.9, '#c4463a'],
[1, '#c4463a']
],
min: -15,
max: 25,
startOnTick: false,
endOnTick: false,
labels: {
format: '{value}℃'
}
},
series: [{
data: [[2017-01-01,0,2.7],[2017-01-02,0,1.7],[2017-01-03,0,-0.7],[2017-01-04,0,2.5],[2017-01-05,0,-6.6],[2017-01-06,0,-9.2],[2017-01-07,0,1.7],[2017-01-08,0,-1.6]],
boostThreshold: 100,
borderWidth: 0,
nullColor: '#EFEFEF',
colsize: 24 * 36e5, // one day
tooltip: {
headerFormat: 'Temperature<br/>',
pointFormat: '{point.x:%e %b, %Y} {point.y}:00: <b>{point.value} ℃</b>'
},
turboThreshold: Number.MAX_VALUE // #3404, remove after 4.0.5 release
}]
});
指向我的JSFiddle的链接:https://jsfiddle.net/4581qd3b/
1条答案
按热度按时间xv8emn3q1#
你有几种方法来给定数据,简单的对象或数组。
现场演示:https://jsfiddle.net/BlackLabel/m84f3spx/2/