diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index e7c24383..b8cccbd7 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -436,13 +436,15 @@ function html_body(plt::Plot{PlotlyBackend}, style = nothing) style = "width:$(w)px;height:$(h)px;" end uuid = Base.Random.uuid4() - """ + html = """
""" + # @show html + html end @@ -479,7 +481,8 @@ function Base.writemime(io::IO, ::MIME"image/png", plt::AbstractPlot{PlotlyBacke end function Base.writemime(io::IO, ::MIME"text/html", plt::AbstractPlot{PlotlyBackend}) - write(io, html_head(plt) * html_body(plt)) + write(io, html_head(plt) * html_body(plt)) + # write(io, html_body(plt)) end function Base.display(::PlotsDisplay, plt::AbstractPlot{PlotlyBackend}) diff --git a/src/backends/plotlyjs.jl b/src/backends/plotlyjs.jl index 1f12358f..ca972d98 100644 --- a/src/backends/plotlyjs.jl +++ b/src/backends/plotlyjs.jl @@ -44,6 +44,7 @@ function _add_series(::PlotlyJSBackend, plt::Plot; kw...) typ = pop!(pdict, :type) gt = PlotlyJS.GenericTrace(typ; pdict...) PlotlyJS.addtraces!(syncplot, gt) + # PlotlyJS.addtraces!(syncplot.plot, gt) push!(plt.seriesargs, d) plt @@ -73,6 +74,7 @@ function _update_plot(plt::Plot{PlotlyJSBackend}, d::Dict) syncplot = plt.o w,h = d[:size] PlotlyJS.relayout!(syncplot, pdict, width = w, height = h) + # PlotlyJS.relayout!(syncplot.plot, pdict, width = w, height = h) end @@ -125,4 +127,3 @@ end function Base.display(::PlotsDisplay, plt::Subplot{PlotlyJSBackend}) error() end - diff --git a/src/output.jl b/src/output.jl index aeb3adfb..4cc18bec 100644 --- a/src/output.jl +++ b/src/output.jl @@ -124,18 +124,18 @@ end # --------------------------------------------------------- function setup_atom() - # @require Atom begin - # @eval begin - # import Atom - # - # Atom.displaysize(::AbstractPlot) = (535, 379) - # Atom.displaytitle(::AbstractPlot) = "Plots.jl" - # - # Atom.@render Atom.PlotPane p::Plot begin - # x, y = Atom.@rpc Atom.plotsize() - # plot!(p, size=(x,y)) # changes the size of the Plots.Plot - # Atom.div(Dict(:style=>"background: white"), Atom.HTML(stringmime("text/html", p))) - # end - # end - # end + @require Atom begin + import Atom, Media + + # connects the render function + Media.media(Plot, Media.Plot) + + # Atom.displaysize(::AbstractPlot) = (535, 379) + # Atom.displaytitle(plt::AbstractPlot) = "Plots.jl (backend: $(backend(plt)))" + + # this is like "display"... sends an html div with the plot to the PlotPane + function Media.render(pane::Atom.PlotPane, plt::Plot) + Media.render(pane, Atom.div(Atom.d(), Atom.HTML(stringmime(MIME("text/html"), plt)))) + end + end end