在Google图表中隐藏特定的图例 [英] Hide specific legend in Google Chart

查看:113
本文介绍了在Google图表中隐藏特定的图例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了面积图的代码,如果我点击特定的标签,就可以隐藏相应的区域,类似于此代码



问题是如果我点击一个特定的图例,相应的区域和所有的图例都隐藏起来。这是因为我在做,

  var options = {legend:'none'}; 

有没有一种方法可以隐藏所点击的图例(以及相应的区域)?

解决方案

您的代码试图隐藏整个图例,而不是图表中基于点击图例中的区域。 p>

尝试查看以下代码: http://jsfiddle.net/ asgallant / 6gz2Q - 您基本上需要以特定方式创建图表,并在点击图例时添加一个选择侦听器来捕获事件:

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

请注意,示例链接中的代码不是我的,但它帮助我完全一样问题。


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.

这篇关于在Google图表中隐藏特定的图例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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