문제

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)?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top