Hiding the legend in Google Chart
Asked Answered
M

5

173

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

Maunsell answered 5/3, 2011 at 5:58 Comment(0)
C
404

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

legend: {position: 'none'}

Carnes answered 30/1, 2012 at 18:39 Comment(4)
This actually works. Haven't tried the other suggestion. Remember should go in the options: var options = {legend:{position:'none'}};Thalia
This removes the title too!Fils
This is exactly what i was looking for, remove all legends etc, work on visualization version 1 "google.load("visualization", "1", { packages: ["bar"] });"Parkin
Google's documentation on charts is so bad.Jodee
T
97

A bit cleaner way is

legend: 'none'
Tamica answered 13/1, 2014 at 18:1 Comment(3)
Still working for me today (17/009/2015). I'm using "google.load('visualization', '1.1', {'packages':['controls', "corechart", "calendar"]});"Coverall
This didn't work for me on 07.10.2016 (dd.mm.yyyy), although the original accepted answer worked.Germanophile
Doesn't work for me on September 23, 2017. The accepted answer works.Forcemeat
A
12
var options = {
               title: 'USA City Distribution',
               legend: 'none'
              };

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

Anastice answered 29/3, 2019 at 13:23 Comment(0)
R
3

In my case I use:

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

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

Ragamuffin answered 6/10, 2016 at 14:59 Comment(0)
P
-7

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.

Primaveria answered 5/3, 2011 at 6:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.