Highcharts 堆叠区域 - 仅在精确区域鼠标悬停后更新工具提示
Highcharts stacked area - update tooltip only after exact area mouse over
我用 Highcharts.js 制作了 stacked area-chart。我只想在光标越过区域之间的边界时更新工具提示。目前,当光标与一个区域边缘之间的距离比光标与相邻区域边缘之间的距离更近时,工具提示会更新(参见 gif)。
我怎样才能达到这种行为?
Highcharts.chart('container', {
chart: {
type: 'area'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
series: {
stacking: 'normal',
trackByArea: true,
}
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2]
}]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
将 trackByArea
设置为 true 并将 stickyTracking
设置为 false 的组合是您正在寻找的解决方案。
演示:https://jsfiddle.net/BlackLabel/e9r2Lmtk/
plotOptions: {
series: {
stacking: 'normal',
trackByArea: true,
stickyTracking: false // to show the difference in tracking
}
},
API: https://api.highcharts.com/highcharts/series.area.trackByArea
API: https://api.highcharts.com/highcharts/series.area.stickyTracking
我用 Highcharts.js 制作了 stacked area-chart。我只想在光标越过区域之间的边界时更新工具提示。目前,当光标与一个区域边缘之间的距离比光标与相邻区域边缘之间的距离更近时,工具提示会更新(参见 gif)。
我怎样才能达到这种行为?
Highcharts.chart('container', {
chart: {
type: 'area'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
series: {
stacking: 'normal',
trackByArea: true,
}
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2]
}]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
将 trackByArea
设置为 true 并将 stickyTracking
设置为 false 的组合是您正在寻找的解决方案。
演示:https://jsfiddle.net/BlackLabel/e9r2Lmtk/
plotOptions: {
series: {
stacking: 'normal',
trackByArea: true,
stickyTracking: false // to show the difference in tracking
}
},
API: https://api.highcharts.com/highcharts/series.area.trackByArea
API: https://api.highcharts.com/highcharts/series.area.stickyTracking