diff --git a/src/backends/plotly-latest.min.js b/deps/plotly-latest.min.js similarity index 100% rename from src/backends/plotly-latest.min.js rename to deps/plotly-latest.min.js diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 21bc6cd8..544b7284 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -71,52 +71,79 @@ function Base.writemime(io::IO, ::MIME"image/png", plt::PlottingObject{PlotlyPac # TODO: write a png to io end -function open_browser_window(filename::AbstractString) - @osx_only return run(`open $(filename)`) - @linux_only return run(`xdg-open $(filename)`) - @windows_only return run(`$(ENV["COMSPEC"]) /c start $(filename)`) - warn("Unknown OS... cannot open browser window.") + +# function build_plotly_json() +# end + +const _pyplot_head_template = mt""" + +""" + +const _pyplot_body_template = mt""" +
+ +""" + + +function html_head(plt::Plot{PlotlyPackage}) + render(_pyplot_head_template, src = Pkg.dir("Plots","deps","plotly-latest.min.js")) end -function build_plotly_json() +function html_body(plt::Plot{PlotlyPackage}) + w, h = plt.plotargs[:size] + + # TODO: get the real ones + seriesargs = [Dict(:x => collect(1:5), :y => rand(5))] + plotargs = Dict(:margin => 0) + + render(_pyplot_body_template, + width=w, + height=h, + seriesargs = JSON.json(seriesargs), + plotargs = JSON.json(plotargs) + ) end function Base.display(::PlotsDisplay, plt::Plot{PlotlyPackage}) + standalone_html_window(plt) - filename = string(tempname(), ".html") - output = open(filename, "w") - w, h = plt.plotargs[:size] + # filename = string(tempname(), ".html") + # output = open(filename, "w") + # w, h = plt.plotargs[:size] - write(output, - """ - - - -