Santosh
Santosh

Reputation: 885

Toggling legend text click event in highcharts

How to reset its original chart value after legendItem toggle event? RESET legendItemClick:

function(event) 
                {
                    var seriesIndex = this.index;
                    var series = this.chart.series;

                    for (var i = 0; i < series.length; i++)
                    {
                        if (series[i].index != seriesIndex)
                        {
                            series[i].hide();
                        } 
                        else
                        {
                            series[i].show();    
                        }
                    }
                    return false;
                }

Note: Currently this code works like RADIO button event[toggle]; How to make this work like a CHECKBOX event with a condition where user cannot uncheck both! But can check both the events!!! :-D

Upvotes: 1

Views: 1813

Answers (1)

Santosh
Santosh

Reputation: 885

I was able to find the solution to the above question from my peer...there might be better way using some API's... here is the link to SOLUTION

legendItemClick: function(event) 
            {
                var seriesIndex = this.index;
                var series = this.chart.series;
                var visibleCount= 0;
                var visibleIndex= 0;
                for (var i = 0; i < series.length; i++)
                {
                    if (series[i].visible)
                    {
                        visibleIndex =i;
                        visibleCount++;
                    }
                }
                if (visibleCount===1  && visibleIndex === seriesIndex)
                {
                    event.preventDefault();
                }
            }

Upvotes: 2

Related Questions