Re: Making Legends toggle their elements

51 views
Skip to first unread message

asgallant

unread,
Jun 20, 2012, 11:11:35 PM6/20/12
to google-visua...@googlegroups.com
Hmmm...you could use a DataView to double-up on your data columns, making a duplicate of each one.  The duplicates would have null values, but be included in the legend, while the ones containing data would be excluded from the legend.  Use a select event handler to grab clicks on the chart elements (check for null rows to detect legend clicks vis-a-vis other elements), and then hide or add the associated columns and redraw.  I think I wrote up an example of this some time back...let me dig through the archives for a minute here...ah yes, here you go:  http://jsfiddle.net/MuC37/ 

There is a lot of stuff to keep track of to make it work right, so read the code carefully.

On Tuesday, June 19, 2012 5:56:16 PM UTC-4, Benjamin Press wrote:
So, I'm working on a few things, and one thing I want to do is to have the legend's elements sort of act like check boxes. I want to be able to turn off elements/data by clicking their entry in the legend. However, from what I've been reading, that would remove the legend element as well as the element on the chart, thus making it impossible to bring the data back. Does anyone know of a workaround for this?
Reply all
Reply to author
Forward
0 new messages