JuliaGraphics / Immerse.jl

Dive deeper into your data with interactive graphics
Other
89 stars 13 forks source link

Toggle series visibility #5

Open tbreloff opened 9 years ago

tbreloff commented 9 years ago

Can you pick up mouse-clicks on a Gadfly legend? If so it would be great to implement the feature of clicking on an item in the legend to hide/show the series in the underlying plot using the setproperty!((hfig,:line), true, :visible) command.

timholy commented 9 years ago

Ooh, like that idea!

Not a problem in principle. I've got to shift to other things now, but I can look into this later. If you want to dig into this yourself, here's how I'd go about it:

# render your figure
julia> showcompact(f.cc)

(EDIT: that was unreadable. This is better.)

Now look at the output and figure out which Context contains the legend. For example, the main plot area is "labeled" with an svgc(plotpanel). Hopefully legends get an svgc label too.

Assuming you find something, we can modify drawpart to report the coordinates of the legend, just as it does the plotpanel.

One last step will be to do coordinate transformations sort of like here to determine which one the user clicked on.

timholy commented 9 years ago

(Obviously, checking the Gadfly source for how it renders legends might be informative :smile:)