Hiding the legend in Google Chart

JavascriptGoogle Visualization

Javascript Problem Overview


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

Javascript Solutions


Solution 1 - Javascript

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

legend: {position: 'none'}

Solution 2 - Javascript

A bit cleaner way is

legend: 'none'

Solution 3 - Javascript

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

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

Solution 4 - Javascript

In my case I use:

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

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

Solution 5 - Javascript

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.

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjamesathaView Question on Stackoverflow
Solution 1 - JavascriptTrevor PesoutView Answer on Stackoverflow
Solution 2 - JavascriptdimusView Answer on Stackoverflow
Solution 3 - JavascriptNilesh BundeView Answer on Stackoverflow
Solution 4 - JavascriptJhonny PamponetView Answer on Stackoverflow
Solution 5 - JavascriptBrandon FrohbieterView Answer on Stackoverflow