Hi everyone,
In this post from last Wednesday, Hans-Peter pointed out that plotly.js was made open source ( https://plot.ly/javascript/open-source-announcement/ ).
Anyway, I tried my hands at writing a wrapper for the JS API. There already exists Plotly.jl, but that is an API to interact with the company's server requiring login info, etc. With the opening of the JS API, the interaction between Julia and Plotly can be much simpler, I think.
In the other post, I mused that it should be straightforward to hook up Plotly.js with Juno, so here is a snapshot:
To make it interactive, I used WebSockets.jl. One neat artifact of that is you can stream the charts to multiple connections.
Here is a silly video demo of me controlling 4 browsers (only 3 are visible) including an iPhone from Juno: https://www.youtube.com/watch?v=mWDyyfVNqP0
The same concept should work with Vega.jl in Juno.
I call this a "Pre-announcement", because it is not really ready for the wild yet, but it is far enough that if some friendlies would like to have a look and help me get it in shape, that would be more than welcome.
Currently, I am struggling a bit to get the paths correct. If I "git clone" it and run it from the REPL, then I can make it work, but if I "Pkg.clone" it, the path to the html containing the scripts is wrong.
Here are the lines in question:
# res = Response(open(readall,Pkg.dir("Plotly","src","web","plotly.html")))
res = Response(open(readall,"web/plotly.html"))
Try using dirname(@__FILE__) instead of Pkg.dir
julia>Pkg.clone("https://github.com/EricForgy/PlotlyJS.jl.git")
julia> using PlotlyJSListening on 0.0.0.0:8000...
julia> include(Pkg.dir("plotlyJS","test","runtests.jl"))
By now, there are several ways to get Julia working with Plotly. My solution launches its own HttpServer so it can work in any browser. Atom, being basically an "unsafe" browser, has a couple packages to let you open web pages. In my screenshots above, I installed one of these Atom packages and opened up the URL for the HttpServer my PlotlyJS launches, so yes, it works in Atom, but through a separate browser package.
If you look at my code, there is nothing much specific to Plotly in there and whatever is specific to Plotly can be easily removed. It simply connects Julia to your browser and lets you manipulate the DOM interactively similar to Escher, but in a way that gives you access to any JavaScript library. In this Pre-Ann, I am controlling both d3.js and plotly.js directly from the REPL, but the same idea will work for any JavaScript, so I might change the name to JavaScript.jl or something a little more creative :)