use_remote for plotly html output

This commit is contained in:
Tom Breloff 2016-11-28 11:02:32 -05:00
parent 8204b51213
commit 90e655d979
2 changed files with 8 additions and 1 deletions

View File

@ -57,6 +57,7 @@ end
const _plotly_js_path = joinpath(dirname(@__FILE__), "..", "..", "deps", "plotly-latest.min.js") const _plotly_js_path = joinpath(dirname(@__FILE__), "..", "..", "deps", "plotly-latest.min.js")
const _plotly_js_path_remote = "https://cdn.plot.ly/plotly-latest.min.js"
function _initialize_backend(::PlotlyBackend; kw...) function _initialize_backend(::PlotlyBackend; kw...)
@eval begin @eval begin
@ -629,8 +630,12 @@ end
# ---------------------------------------------------------------- # ----------------------------------------------------------------
const _use_remote = Ref(false)
function html_head(plt::Plot{PlotlyBackend}) function html_head(plt::Plot{PlotlyBackend})
"<script src=\"$(joinpath(dirname(@__FILE__),"..","..","deps","plotly-latest.min.js"))\"></script>" jsfilename = _use_remote[] ? _plotly_js_path_remote : _plotly_js_path
# "<script src=\"$(joinpath(dirname(@__FILE__),"..","..","deps","plotly-latest.min.js"))\"></script>"
"<script src=\"$jsfilename\"></script>"
end end
function html_body(plt::Plot{PlotlyBackend}, style = nothing) function html_body(plt::Plot{PlotlyBackend}, style = nothing)

View File

@ -55,7 +55,9 @@ tex(fn::AbstractString) = tex(current(), fn)
function html(plt::Plot, fn::AbstractString) function html(plt::Plot, fn::AbstractString)
fn = addExtension(fn, "html") fn = addExtension(fn, "html")
io = open(fn, "w") io = open(fn, "w")
_use_remote[] = true
show(io, MIME("text/html"), plt) show(io, MIME("text/html"), plt)
_use_remote[] = false
close(io) close(io)
end end
html(fn::AbstractString) = html(current(), fn) html(fn::AbstractString) = html(current(), fn)