我使用的是 Highcharts 柱形图 ( http://www.highcharts.com/demo/column-basic ),其中包含超过 50 行数据和 3 个不同的系列。由于此数量和图表宽度限制,x 轴标签靠近并聚集在一起。
当用户将鼠标悬停在图表内的点/列上时,我想加粗或更改 x 轴标签的颜色。我知道您可以绑定到每个点的事件(http://api.highcharts.com/highcharts#plotOptions.column.point.events),但我无法将任何样式更改链接到 x 轴标签由此。这是一个 jsFiddle ( http://bit.ly/SpPvCW ),其中包含该点上的事件。代码块如下所示:
plotOptions: {
series: {
point: {
events: {
mouseOver: function() {
$reporting.html('x: '+ this.x +', y: '+ this.y);
}
}
},
events: {
mouseOut: function() {
$reporting.empty();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
此 jsFiddle ( http://jsfiddle.net/4h7DW/1/ ) 包含一个柱形图,其中 x 轴标签旋转。
xAxis: {
labels: {
rotation: -70,
align: 'right',
style: {
fontSize: '10px',
color:'#999',
fontFamily: 'Verdana, sans-serif'
}
}
},
Run Code Online (Sandbox Code Playgroud)
同样,目标是当您悬停关联的列/点时加粗或更改 x 轴标签的颜色。
这是我刚刚创建的一个快速示例。我累了,还可以改进。它通过点索引将轴标签链接到鼠标悬停:
series: {
point: {
events: {
mouseOver: function() {
$(this.series.chart.xAxis[0].labelGroup.element.childNodes[this.x]).css('fill', 'black');
},
mouseOut: function() {
$(this.series.chart.xAxis[0].labelGroup.element.childNodes[this.x]).css('fill', '#999999');
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在这里摆弄。