From 8922124d215262ee9c826c33577b77428ff4ae79 Mon Sep 17 00:00:00 2001 From: Matti Pastell Date: Tue, 1 Nov 2016 10:40:40 +0200 Subject: [PATCH] Added support for Plots/PlotlyJS backend html/javascript output, #35 --- src/plots.jl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/plots.jl b/src/plots.jl index 6544c57..7b258e7 100644 --- a/src/plots.jl +++ b/src/plots.jl @@ -10,6 +10,7 @@ end push_preexecute_hook(plots_set_size) +#PNG or SVG is not working, output html function Base.display(report::Report, m::MIME"image/svg+xml", data::Plots.Plot{Plots.PlotlyBackend})# #Remove extra spaces from start of line for pandoc s = reprmime(MIME("text/html"), data) @@ -27,3 +28,28 @@ function Base.display(report::Report, m::MIME"image/svg+xml", data::Plots.Plot{P report.rich_output *= "\n" * div * "\n" * plot end + +#PNG or SVG is not working, output html +function Base.display(report::Report, m::MIME"image/svg+xml", plot::Plots.Plot{Plots.PlotlyJSBackend}) + script = "" + body = Plots.PlotlyJS.html_body(plot.o.plot) + + if report.first_plot + report.rich_output *= "\n" * script + report.first_plot = false + end + + report.rich_output *= "\n" * body +end + +function Base.display(report::Report, m::MIME"image/png", plot::Plots.Plot{Plots.PlotlyJSBackend}) + script = "" + body = Plots.PlotlyJS.html_body(plot.o.plot) + + if report.first_plot + report.rich_output *= "\n" * script + report.first_plot = false + end + + report.rich_output *= "\n" * body +end