how do i make legend disappear on a chart?

10,385 views
Skip to first unread message

doles

unread,
Aug 25, 2011, 12:24:17 PM8/25/11
to google-visua...@googlegroups.com
New to google charts!! I cant find a method/function to remove the legend from a chart. What I ultimately want to achieve is to include 3 pie charts in one area and have them use the same legend. so one full pie shows accept/warn/reject of a certain characteristic, the second shows another char and the third yet another. so, i want to show only one legend and not repeat it for the three. i am looking into the dashboard mechanism, however, if you guys have any ideas for me, i will be thankful.!

--
doles

Riccardo Govoni ☢

unread,
Aug 25, 2011, 12:38:14 PM8/25/11
to google-visua...@googlegroups.com
It should be enough for you to pass the legend: 'none' option (http://code.google.com/apis/chart/interactive/docs/gallery/piechart.html#Configuration_Options) to 2 out of the 3 pie charts you have.

(assuming all the pies show the same type of data, so one legend from one would work equally well for all the others. If you want to aggregate 3 separate legends with different contents into a single one there is not currently a readymade option to do that, so you'll have to do it on your own).
/R.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/B60A99umut4J.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

doles

unread,
Aug 25, 2011, 12:51:52 PM8/25/11
to google-visua...@googlegroups.com
Thanks for replying. Yes, that I could certainly do (marking legend:'none'). however, then, i lose control over where to show the legend and the way i need to lay it out, it does not look good. What would be ideal is to combine three pies in one unit and apply a legend to the entire unit. 

I checked out the dashboard project. It looks promising, however, only examples if found were ones where a control or a set of controls was being bound to charts. how does one actually combine charts and then apply options such as legend on the combined set of charts without any controls? 

Lastly, it looks like there is no way to actually read through the google charts api if we wanted to write a wrapper or if we wanted to extend it. is that true? For example, I use the gwt-visualization tool to use this in a gwt project. but without a debug version of the js file which I can read and make sense of, I cant really write gwt overlay types. So,where do i get a human readable version of the chart javascript file?

doles

doles

unread,
Aug 25, 2011, 2:00:33 PM8/25/11
to google-visua...@googlegroups.com
besides, marking legend to 'none' does not work because it makes two pie charts expand to take up the space that the legend left empty. so i get two big pies and one small. :-(  

visigoth

unread,
Aug 28, 2011, 10:05:06 AM8/28/11
to google-visua...@googlegroups.com
As Riccardo mentioned, an external legend component for controlling more than a single chart is currently not available.

However, you can try the following hack:
Create 3 Pie charts with legend: 'none' to make sure they all have the same size and layout.
Create a ColumnChart and set its chartArea option to {top0left0width0height<height>}.
This way the only thing shown out of the column chart is the legend.

For interactivity with the legend, you can listen on the legend entries hover and click events and set the selection of the other charts accordingly (right now you cannot set the hover effect though).

Hope this helps,
visigoth

Reply all
Reply to author
Forward
0 new messages