在Highcharts中显示隐形系列的工具提示 [英] Display tooltip for invisible series in Highcharts

查看:85
本文介绍了在Highcharts中显示隐形系列的工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



将鼠标悬停在图表上时,可以看到工具提示仅包含系列2中的值,但不包含系列1中的值(这是不可见的)。当你点击图例中的系列1时,你可以在工具提示中看到系列1的值。



编辑:no code 要提交,只需修改linkrot /遵守编辑规则...

有什么方法可以在工具提示中显示隐形系列中的值吗?

$ b $ 工具提示:{
格式化程序:function(){$ b $ 解决方案

var chart = this.points [0] .series.chart; //获取图表对象
var categories = chart.xAxis [0] .categories; //获取类别数组
var index = 0;
while(this.x!== categories [index]){index ++;} //计算每个数据数组中的corr y值的索引
$ .each(chart.series,function(i,系列){//通过系列数组循环
s + ='< br />'+ series.name +':'+
series.data [index] .y +'m'; / /使用索引来获得y值
});
return s;
},
共享:true
}


I am trying to display a custom tooltip using Highcharts. You can find an example of the code here: http://jsfiddle.net/jalbertbowdenii/fDNh9/188/

When you hover over the chart, you can see that the tooltip only contains values from Series 2, but not from Series 1 (which is invisible). When you click on "Series 1" in the legend, you can see the values from Series 1 in the tooltip.

EDIT: no code to commit, just fixing linkrot/adhering to editing rules...
Is there any way to display the values from an invisible series in a tooltip?

解决方案

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
}

这篇关于在Highcharts中显示隐形系列的工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆