working on atom/plotly
This commit is contained in:
parent
8b2a838388
commit
c203bfe5ad
@ -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 = """
|
||||
<div id=\"$(uuid)\" style=\"$(style)\"></div>
|
||||
<script>
|
||||
PLOT = document.getElementById('$(uuid)');
|
||||
Plotly.plot(PLOT, $(get_series_json(plt)), $(get_plot_json(plt)));
|
||||
</script>
|
||||
"""
|
||||
# @show html
|
||||
html
|
||||
end
|
||||
|
||||
|
||||
@ -480,6 +482,7 @@ end
|
||||
|
||||
function Base.writemime(io::IO, ::MIME"text/html", plt::AbstractPlot{PlotlyBackend})
|
||||
write(io, html_head(plt) * html_body(plt))
|
||||
# write(io, html_body(plt))
|
||||
end
|
||||
|
||||
function Base.display(::PlotsDisplay, plt::AbstractPlot{PlotlyBackend})
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -124,18 +124,18 @@ end
|
||||
# ---------------------------------------------------------
|
||||
|
||||
function setup_atom()
|
||||
# @require Atom begin
|
||||
# @eval begin
|
||||
# import Atom
|
||||
#
|
||||
@require Atom begin
|
||||
import Atom, Media
|
||||
|
||||
# connects the render function
|
||||
Media.media(Plot, Media.Plot)
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user