在Highcharts中显示隐形序列的工具提示

j0n*_*nes 11 javascript highcharts

我正在尝试使用Highcharts显示自定义工具提示.你可以在这里找到代码的例子:http: //jsfiddle.net/jalbertbowdenii/fDNh9/188/

将鼠标悬停在图表上时,可以看到工具提示仅包含系列2中的值,但不包含系列1中的值(不可见).单击图例中的"系列1"时,可以在工具提示中查看系列1中的值.

编辑:不code提交,只修复linkrot /遵守编辑规则...
有没有办法在工具提示中显示隐形序列中的值?

Bhe*_*ung 13

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
}
Run Code Online (Sandbox Code Playgroud)