检测单击,然后在Highcharts的面积图上为x轴添加悬停/选定样式? [英] Detect a click on, and add hover/selected style for x axis on area chart in Highcharts?
问题描述
图表示例: http://www.highcharts.com/demo/area-stacked -百分比
1)我是否可以具有x轴的悬停样式,也可以是选定样式,就像在Highstocks中一样(将鼠标移到图表上以查看悬停的垂直线):
1) Can I have a hover style and also perhaps a selected style for the x axis, much like in Highstocks (move the mouse over the chart to see a vertical line on hover): http://www.highcharts.com/stock/demo/area
2)我可以检测到对此行的点击吗?
2) Can I detect a click on this line?
推荐答案
我可以像在Highstock中一样具有悬浮样式以及x轴的选定样式吗?
Can I have a hover style and also perhaps a selected style for the x axis, much like in Highstock
当然可以.在 plotOptions
.
plotOptions: {
series: {
marker: {
states: {
hover: { enabled: true }
}
}
}
}
启用十字准线
tooltip: {
crosshairs: true
}
我可以检测到对此行的点击吗?
Can I detect a click on this line?
要在单击该行时触发警报,只需添加
For triggering an alert upon clicking the line, just add
plotOptions: {
series: {
point: {
events: {
click: function() {
alert ('Clicked on the line');
}
}
}
}
}
针对两个问题的组合答案,经过修饰的版本为 here
一个>.
combined answer for both of your questions, fiddled version is here
.
这篇关于检测单击,然后在Highcharts的面积图上为x轴添加悬停/选定样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!