javascript – 在Highcharts中显示隐形系列的工具提示

前端之家收集整理的这篇文章主要介绍了javascript – 在Highcharts中显示隐形系列的工具提示前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图使用Highcharts显示一个自定义的工具提示.你可以在这里找到代码的例子:
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
}
原文链接:https://www.f2er.com/js/154289.html

猜你在找的JavaScript相关文章