plotly / Dash.jl

Dash for Julia - A Julia interface to the Dash ecosystem for creating analytic web applications in Julia. No JavaScript required.
MIT License
489 stars 40 forks source link

Support figures generated by Plots.jl with a PlotlyBackend #214

Closed mbauman closed 1 year ago

mbauman commented 1 year ago

Given that Plots.jl supports Plotly as a backend — and can generate the requisite key-value blobs that Dash needs — it'd be very nice to use that as the unified plotting API as an easy path. And this is really easy to support. All we need is this one line of code:

import Dash, Plots
Dash.DashBase.to_dash(p::Plots.Plot{Plots.PlotlyBackend}) = (data = Plots.plotly_series(p), layout = Plots.plotly_layout(p))

So it'd be great if we could wire up Plots as a weakdep (with both Requires for v1.8 and below and Extensions on v1.9+) and define that very simple line of code, which enables very straightforward usage like this:

app = Dash.dash()
app.layout = Dash.html_div() do
    Dash.html_h1("Dash 🤝 Plots"),
    Dash.dcc_graph(id = "test", figure= Plots.plot(1:10, rand(10)))
end
etpinard commented 1 year ago

Good idea!

If anyone seeing this is interested in making PR, the required patch would have to be in https://github.com/plotly/DashBase.jl