我试图使用Highcharts显示一个自定义的工具提示.你可以在这里找到代码的例子:
http://jsfiddle.net/jalbertbowdenii/fDNh9/188/
http://jsfiddle.net/jalbertbowdenii/fDNh9/188/
当您将鼠标悬停在图表上时,您可以看到工具提示仅包含系列2中的值,但不包含系列1中的值(不可见).当您点击图例中的“系列1”时,您可以在工具提示中看到系列1的值.
编辑:没有代码提交,只需修复linkrot /恪守编辑规则…
有没有办法在工具提示中显示不可见系列的值?
解决方法
tooltip: {
formatter: function() {
var s = '<b>'+ this.x +'</b>';
var chart = this.points[0].series.chart; //get the chart object
var categories = chart.xAxis[0].categories; //get the categories array
var index = 0;
while(this.x !== categories[index]){index++;} //compute the index of corr y value in each data arrays
$.each(chart.series,function(i,series) { //loop through series array
s += '<br/>'+ series.name +': ' +
series.data[index].y +'m'; //use index to get the y value
});
return s;
},shared: true
}