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;"
|
style = "width:$(w)px;height:$(h)px;"
|
||||||
end
|
end
|
||||||
uuid = Base.Random.uuid4()
|
uuid = Base.Random.uuid4()
|
||||||
"""
|
html = """
|
||||||
<div id=\"$(uuid)\" style=\"$(style)\"></div>
|
<div id=\"$(uuid)\" style=\"$(style)\"></div>
|
||||||
<script>
|
<script>
|
||||||
PLOT = document.getElementById('$(uuid)');
|
PLOT = document.getElementById('$(uuid)');
|
||||||
Plotly.plot(PLOT, $(get_series_json(plt)), $(get_plot_json(plt)));
|
Plotly.plot(PLOT, $(get_series_json(plt)), $(get_plot_json(plt)));
|
||||||
</script>
|
</script>
|
||||||
"""
|
"""
|
||||||
|
# @show html
|
||||||
|
html
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -479,7 +481,8 @@ function Base.writemime(io::IO, ::MIME"image/png", plt::AbstractPlot{PlotlyBacke
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Base.writemime(io::IO, ::MIME"text/html", plt::AbstractPlot{PlotlyBackend})
|
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
|
end
|
||||||
|
|
||||||
function Base.display(::PlotsDisplay, plt::AbstractPlot{PlotlyBackend})
|
function Base.display(::PlotsDisplay, plt::AbstractPlot{PlotlyBackend})
|
||||||
|
|||||||
@ -44,6 +44,7 @@ function _add_series(::PlotlyJSBackend, plt::Plot; kw...)
|
|||||||
typ = pop!(pdict, :type)
|
typ = pop!(pdict, :type)
|
||||||
gt = PlotlyJS.GenericTrace(typ; pdict...)
|
gt = PlotlyJS.GenericTrace(typ; pdict...)
|
||||||
PlotlyJS.addtraces!(syncplot, gt)
|
PlotlyJS.addtraces!(syncplot, gt)
|
||||||
|
# PlotlyJS.addtraces!(syncplot.plot, gt)
|
||||||
|
|
||||||
push!(plt.seriesargs, d)
|
push!(plt.seriesargs, d)
|
||||||
plt
|
plt
|
||||||
@ -73,6 +74,7 @@ function _update_plot(plt::Plot{PlotlyJSBackend}, d::Dict)
|
|||||||
syncplot = plt.o
|
syncplot = plt.o
|
||||||
w,h = d[:size]
|
w,h = d[:size]
|
||||||
PlotlyJS.relayout!(syncplot, pdict, width = w, height = h)
|
PlotlyJS.relayout!(syncplot, pdict, width = w, height = h)
|
||||||
|
# PlotlyJS.relayout!(syncplot.plot, pdict, width = w, height = h)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -125,4 +127,3 @@ end
|
|||||||
function Base.display(::PlotsDisplay, plt::Subplot{PlotlyJSBackend})
|
function Base.display(::PlotsDisplay, plt::Subplot{PlotlyJSBackend})
|
||||||
error()
|
error()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -124,18 +124,18 @@ end
|
|||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
function setup_atom()
|
function setup_atom()
|
||||||
# @require Atom begin
|
@require Atom begin
|
||||||
# @eval begin
|
import Atom, Media
|
||||||
# import Atom
|
|
||||||
#
|
# connects the render function
|
||||||
# Atom.displaysize(::AbstractPlot) = (535, 379)
|
Media.media(Plot, Media.Plot)
|
||||||
# Atom.displaytitle(::AbstractPlot) = "Plots.jl"
|
|
||||||
#
|
# Atom.displaysize(::AbstractPlot) = (535, 379)
|
||||||
# Atom.@render Atom.PlotPane p::Plot begin
|
# Atom.displaytitle(plt::AbstractPlot) = "Plots.jl (backend: $(backend(plt)))"
|
||||||
# x, y = Atom.@rpc Atom.plotsize()
|
|
||||||
# plot!(p, size=(x,y)) # changes the size of the Plots.Plot
|
# this is like "display"... sends an html div with the plot to the PlotPane
|
||||||
# Atom.div(Dict(:style=>"background: white"), Atom.HTML(stringmime("text/html", p)))
|
function Media.render(pane::Atom.PlotPane, plt::Plot)
|
||||||
# end
|
Media.render(pane, Atom.div(Atom.d(), Atom.HTML(stringmime(MIME("text/html"), plt))))
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user