Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use webio for Juno integration #231

Merged
merged 1 commit into from
Sep 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)