JS小提琴:http://jsfiddle.net/yondaimehokage/nbxka08u/5/
Highcharts.chart('container', {
chart: {
type: 'heatmap',
marginTop: 40,
marginBottom: 80,
plotBorderWidth: 1
},
title: {
text: 'Sales per employee per weekday'
},
xAxis: {
},
yAxis: {
title: null
},
colorAxis: {
min: 0,
minColor: '#FFFFFF',
maxColor: Highcharts.getOptions().colors[0]
},
legend: {
align: 'right',
layout: 'vertical',
margin: 0,
verticalAlign: 'top',
y: 25,
symbolHeight: 280
},
tooltip: {
formatter: function () {
return '<b>' + this.series.xAxis.categories[this.point.x] + '</b> sold <br><b>' +
this.point.value + '</b> items on <br><b>' + this.series.yAxis.categories[this.point.y] + '</b>';
}
},
series: [{
name: 'Sales per employee',
borderWidth: 1,
data: [[0, 0, 10], [1, 0, 19], [2,0, 8], [3, 0, 24], [4, 0, 67], [5, 0, 2], [6, 0, 16], [7, 0, 10], [8, 0, 5], [9, 0, 50]],
dataLabels: {
enabled: true,
color: '#000000'
}
}]
});
有没有办法让X轴标签跨越x轴区域,这取决于值?
简而言之,我有一张使用HighCharts的热图图表。我想尝试实现这样的目标(抱歉Windows Paint渲染):
因此,根据值,X轴颜色会发生变化,标签的居中位置将相对于与该数据标签对应的值的范围。
有什么想法可以做到这一点?刻度标记不起作用,这不是我需要标签出现的常规间隔。
编辑:根据评论,我想我需要找出一种方法来计算X值“条”范围占用的像素宽度。那么X值为1到10的点占用的“条形”有多少像素,X值为11到25的点占据的“条形”有多少像素,依此类推。 / p>