Skip to content

Commit

Permalink
Merge pull request #231 from pfitzseb/sp/juno
Browse files Browse the repository at this point in the history
use webio for Juno integration
  • Loading branch information
sglyon authored Sep 27, 2018
2 parents 7d89b85 + 98899fe commit 4f526e0
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions src/display.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
# juno integration
function Base.show(io::IO, ::MIME"application/juno+plotpane", p::Plot)
content = """
<html>
<head>
<script src="file://$(_js_path)"></script>
</head>
<body>
$(html_body(p))
</body>
</html>
"""
print(io, content)
end

# ----------------------------------------- #
# SyncPlot -- sync Plot object with display #
# ----------------------------------------- #
Expand All @@ -27,6 +12,7 @@ Base.getindex(p::SyncPlot, key) = p.scope[key] # look up Observables

WebIO.render(p::SyncPlot) = WebIO.render(p.scope)
Base.show(io::IO, mm::MIME"text/html", p::SyncPlot) = show(io, mm, p.scope)
Base.show(io::IO, mm::MIME"application/juno+plotpane", p::SyncPlot) = show(io, mm, p.scope)

function SyncPlot(
p::Plot;
Expand Down Expand Up @@ -160,7 +146,7 @@ Base.size(sp::SyncPlot) = size(sp.plot)
Base.copy(sp::SyncPlot) = SyncPlot(copy(sp.plot), options=copy(sp.options))

Base.display(::PlotlyJSDisplay, p::SyncPlot) = display_blink(p::SyncPlot)

function display_blink(p::SyncPlot)
p.window = Blink.Window()
Blink.body!(p.window, p.scope)
Expand Down Expand Up @@ -400,14 +386,12 @@ The default is `:local`
savehtml


for mime in [
"text/plain", "application/juno+plotpane",
"application/vnd.plotly.v1+json"
]
for mime in ["text/plain", "application/vnd.plotly.v1+json"]
function Base.show(io::IO, m::MIME{Symbol(mime)}, p::SyncPlot, args...)
show(io, m, p.plot, args...)
end
end

PlotlyBase.savejson(sp::SyncPlot, fn::String) = PlotlyBase.savejson(sp.plot, fn)
savehtml(io::IO, p::SyncPlot, js::Symbol=js_default[]) = savehtml(io, p.plot, js)
savehtml(p::SyncPlot, fn::AbstractString, js::Symbol=js_default[]) = savehtml(p.plot, fn, js)

0 comments on commit 4f526e0

Please sign in to comment.