Question

I have written code for Area Chart which has the functionality to hide the corresponding area if I click on a particular label, similar to this code.

The problem is if I click on a particular legend, the corresponding area and ALL legends are getting hidden. This is happening because I am doing,

var options = {legend: 'none'}; 

Is there a way that I can hide only the clicked legend (along with the corresponding area)?

Was it helpful?

Solution

Your code is trying to hide the whole legend, not an area in the chart based on a click in a legend.

Trying looking at this code: http://jsfiddle.net/asgallant/6gz2Q - you basically need to create your chart in a specific way and add an on select listener to catch the event when the legend is clicked:

google.visualization.events.addListener(chart, 'select', function(){
   ...
});

Please note, the code in the example link is not mine, but it helped me with the same exact problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top