简体   繁体   English

Highcharts图例事件单击以获取数据

[英]Highcharts Legend event click to get data

I am working on a Scatterplot + Plot lines chart, which has multiple legends. 我正在使用Scatterplot + Plot折线图,其中包含多个图例。 I have to change the value of the plot lines based on the scatterplot values. 我必须根据散点图值更改绘图线的值。 Could anyone help me out in getting the scatter plot value once I click on any legend items? 单击任何图例项后,有人可以帮助我获得散点图的值吗?

I have done this code, Which gives me an alert when I click on any legend. 我已经完成了这段代码,当我单击任何图例时都会发出警报。 Next, I have to get the scatterplot value and change the plot line graph 接下来,我必须获取散点图值并更改绘图线图

 events: {
                legendItemClick: function(e) {
                    if(this.visible) {

                        alert('visible');


                    }
                    else {
                         console.log("result"+result);
                        alert('Not visible');

                    }
                }
            }, 

I have done something similar but for series Plot, but this will surely give you the approach you need to adopt. 我做了类似的事情,但是对于系列图,但这肯定会为您提供您需要采用的方法。

if(series.name=='xyz'){//you can handle multiple legends by checking their name and have different calls for different legends

                    if (!this.visible) {// i want to make request for data only if when i click the legend and its visible 
                    $.getJSON('xyzdata.php',{parameter1:xyz1,parameter2:xyz2}, function(data) {// making the call 
                        series.setData(data.a);// with the returned data defining my plot
                        series.xAxis.setCategories(data.b);
                    });

 };

Hope that helps! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM