Javascript 在 Google Chart 中隐藏图例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5202029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 16:09:19  来源:igfitidea点击:

Hiding the legend in Google Chart

javascriptgoogle-visualization

提问by jamesatha

I am using the Google charts API. Is there a way to hide the legend for a scatter plot?

我正在使用 Google 图表 API。有没有办法隐藏散点图的图例?

回答by Trevor Pesout

You can disable the legend by using 'none' as the position:

您可以使用 'none' 作为位置来禁用图例:

legend: {position: 'none'}

legend: {position: 'none'}

回答by dimus

A bit cleaner way is

更清洁的方法是

legend: 'none'

回答by Nilesh Bunde

var options = {
               title: 'USA City Distribution',
               legend: 'none'
              };

In drawChart()function, Add legend: noneproperty in your chart options object

drawChart()功能上,legend: none在图表选项对象中添加属性

回答by Jhonny Pamponet

In my case I use:

在我的情况下,我使用:

library: {legend:{position:'none'}}

图书馆:{图例:{位置:'无'}}

pie_chart @type_values,library: {legend:{position:'none'}}

pie_chart @type_values,库:{legend:{position:'none'}}

回答by Orbit

It doesn't appear so from the API, you can only set a position, with no option for "none". You could probably remove it with javascript though, if you can identify the containing element.

从 API 上看不是这样,您只能设置一个位置,而没有“无”选项。不过,如果您可以识别包含元素,则可以使用 javascript 将其删除。

Edit: it actually appears as though you can omit the chdl= parameter to get a scatter without a legend.

编辑:它实际上看起来好像你可以省略 chdl= 参数来获得没有图例的散点图。