[英]Highcharts hiding series and keeping tooltip
I'm working with Highcharts api. 我正在使用Highcharts API。 I want to hide some series's curves but keep showing all values of all series on tooltip.
我想隐藏一些系列的曲线,但继续在工具提示上显示所有系列的所有值。
For example: 例如:
series: [{
name: 'Cat',
data: [[1, 15], [2, 18], [3, 10]]
}, {
name: 'Dog',
data: [[1, 12], [2, 18], [3, 11]]
}, {
name: 'Rabbit',
data: [[1, 12], [2, 22], [3, 9]]
}]
I want to hide Rabbit's curve and keep all values on tooltip. 我想隐藏Rabbit的曲线,并在工具提示上保留所有值。 If i point mouse on the first point (1) i have to see this values: Cat: 15 Dog: 12 Rabbit: 12
如果我将鼠标指向第一个点(1),则必须看到以下值:猫:15狗:12兔子:12
You can either use series.hide()
or series.setVisible(false,false)
to hide the series. 您可以使用
series.setVisible(false,false)
series.hide()
或series.setVisible(false,false)
来隐藏系列。 This would, in turn, remove the series from tooltip as well so you require a custom tooltip formatter to show the hidden series. 反过来,这也会从工具提示中删除系列,因此您需要自定义工具提示格式化程序以显示隐藏的系列。 Example:
例:
formatter: function () {
var s = '';
var series = this.points[0].series.chart.series;
var key = this.points[0].key;
series.forEach((e,i) => {
if(e){
s += '<br/>' + e.name + ': ' +
e.options.data[key] + 'm';
}
});
return s;
}
Here's a working example: http://jsfiddle.net/hcy6u4ya/ 这是一个工作示例: http : //jsfiddle.net/hcy6u4ya/
It is possible to use series.graph.hide() or series.group.hide() for hiding series graph path: 可以使用series.graph.hide()或series.group.hide()隐藏系列图路径:
function(chart) {
chart.series[2].update({
marker: {
enabled: false,
states: {
hover: {
enabled: false
}
}
},
})
chart.series[2].group.hide();
}
Live example: http://jsfiddle.net/ktjqbc7t/ 实时示例: http : //jsfiddle.net/ktjqbc7t/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.