Added support for Plots/PlotlyJS backend html/javascript output, #35

pull/55/head
Matti Pastell 2016-11-01 10:40:40 +02:00
parent cbdf0e2886
commit 8922124d21
1 changed files with 26 additions and 0 deletions

View File

@ -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 = "<script src=\"https://cdn.plot.ly/plotly-latest.min.js\"></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 = "<script src=\"https://cdn.plot.ly/plotly-latest.min.js\"></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