Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trickle down to SVG plots #125

Closed
bjarthur opened this issue Mar 26, 2018 · 17 comments
Closed

trickle down to SVG plots #125

bjarthur opened this issue Mar 26, 2018 · 17 comments

Comments

@bjarthur
Copy link

Gadfly has zoom/pan functionality included in it's SVG plots (via javascript) which is much nicer than that provided by the Atom GUI. the problem is that events are not trickled down to the plot, but are captured by Atom. is there a way to change this? thanks.

@bjarthur bjarthur changed the title trickling down to SVG plots trickle down to SVG plots Mar 26, 2018
@bjarthur
Copy link
Author

bjarthur commented Apr 3, 2018

@MikeInnes can you perhaps give me a pointer to resolving this issue? would be great to have better Gadfly support in Atom. thanks.

@pfitzseb
Copy link
Member

pfitzseb commented Apr 3, 2018

This is definitely possible, but our API for it isn't very nice. I'll try to come up with something nicer than we have right now.
You could handle it like Plotlyjs.jl, but that seems like overkill for something that should be simpler.

@pfitzseb
Copy link
Member

pfitzseb commented Apr 4, 2018

Changing Gadfly's render method to

import Juno: Juno, @render, media, Media

media(Plot, Media.Plot)

function Juno.render(pp::Juno.PlotPane, p::Plot)
    x, y = Juno.plotsize()
    set_default_plot_size(x*Gadfly.px, (y-1)*Gadfly.px)
    w = Juno.Atom.blinkplot()
    Juno.Atom.Blink.body!(w, HTML(stringmime("text/html", p)))
end

works (mostly) well:
gadfly

Two problems with that right now:

  1. Accessing Juno.Atom and Juno.Atom.Blink is kinda unfortunate. Obviously solvable with a better API.
  2. The Next Plot/Previous Plot buttons break display. This is a bit tricky to get right, unfortunately.

@bjarthur
Copy link
Author

bjarthur commented Apr 4, 2018

it's beautiful, thank you!

do you want to make a PR to Gadfly with this as is? or would you prefer to wait for a better API, and a way to fix the next/prev plot buttons?

this would've taken me months to figure out, so again, thanks!

@bjarthur
Copy link
Author

bjarthur commented May 1, 2018

we're hoping to tag gadfly soon. i would love to include better support for Atom. is there by chance an easy fix for the next/prev buttons?

@pfitzseb
Copy link
Member

pfitzseb commented May 1, 2018

Probably not, but I'll look into it again.

I'm rather busy with 0.7 compatibility at the moment, so no promises :)

@pfitzseb
Copy link
Member

Ok, this is trivial on Juno 0.7 with Julia 0.7 (just define a show method for MIME"image/svg+xml").
Closing.

@bjarthur
Copy link
Author

bjarthur commented Sep 3, 2018

still can't get Gadfly interactivity to work in Juno. here is where show(io::IO, m::MIME"image/svg+xml", p::Plot) is defined. it was actually already there for a long time. if i change SVG to SVGJS in that function definition, which is what enables the interactivity, i can not zoom or pan in atom using julia 7.0, Atom 0.7.5, Juno 0.5.2, etc. can you give me a hint how to fix it? thanks.

maybe it has something to do with these lines? for the time being i have deleted them in my local installation as they were causing a warning:

WARNING: eval from module Media to Gadfly:    
Expr(:where, Expr(:call, Expr(:., :Media, :(:media)), Expr(:::, Expr(:curly, :Type, :T))), Expr(:<:, :T, Gadfly.Plot)) = Expr(:block, #= Symbol("/Users/arthurb/.julia/dev/Media/src/system.jl"):71 =#, Expr(:ref, Array{Any, (1,)}[Media.Plot], 1))

@pfitzseb
Copy link
Member

pfitzseb commented Sep 3, 2018

I think you can remove all Juno specifc code from Gadfly and it should work.

@bjarthur
Copy link
Author

bjarthur commented Sep 3, 2018

i did, and it doesn't. :(

@pfitzseb
Copy link
Member

pfitzseb commented Sep 4, 2018

Ah I see, that's related to JunoLab/atom-julia-client#497. Should be fixed with JunoLab/Atom.jl@1247525.

Regardless of that commit you could also define a show method for MIME"application/juno+plotpane and print a svg data url there. That'll guarantee that Juno's interactivity is disabled.

@bjarthur
Copy link
Author

bjarthur commented Sep 4, 2018

still doesn't work.

defining a MIME"application..." opens the plot in the default web browser, and the interactivity works there of course, but not ideal because it doesn't use the Atom plot panel.

checking out master of Atom and changing the existing MIME"image/svg+xml" to embed javascript puts the plot in Atom. and while Atom's zoom/pan buttons are now not displayed, the plot's are not enabled.

anything else i should try? thanks.

@pfitzseb
Copy link
Member

pfitzseb commented Sep 4, 2018

defining a MIME"application..." opens the plot in the default web browser, and the interactivity works there of course, but not ideal because it doesn't use the Atom plot panel.

That definitely shouldn't happen (and doesn't for me with e.g. the example in the Juno docs).

checking out master of Atom and changing the existing MIME"image/svg+xml" to embed javascript puts the plot in Atom. and while Atom's zoom/pan buttons are now not displayed, the plot's are not enabled.

Not sure what's going on there then. I can't really figure out how to get Gadfly running on 0.7 though to help debugging this (on Gadfly#bjarthur:bja/julia07, Compose#tn/more-v07-fixes and IndirectArrays master).

@pfitzseb pfitzseb reopened this Sep 4, 2018
@bjarthur
Copy link
Author

bjarthur commented Sep 4, 2018

oh, wow, thanks for trying to get gadfly working. probably easiest for you to wait until that Compose PR is merged, as there's lot's of fixes that haven't been pushed to github yet. let me get back to you when we are more ready for you help. thanks!

@tlnagy
Copy link

tlnagy commented Sep 12, 2018

@pfitzseb Now that both Compose#master and the latest Hexagons release support Julia 1.0, could you give this another look? It should be as easy as checking out Gadfly#bja/julia07, Compose#master and doing a Pkg update.

@pfitzseb
Copy link
Member

pfitzseb commented Sep 12, 2018

Ok, this is weird. I'm getting

Uncaught SyntaxError: Unexpected number
Uncaught SyntaxError: Unexpected end of input

from the plot pane, apparently triggered by the first fill="#000000" statement in the code.

We could probably work around this by saving the svg to disk and loading that, much like what happens when the plot is opened in a browser, but I'd still like to find out what's going on here.

@pfitzseb
Copy link
Member

Fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants