allow plotly json saving

This commit is contained in:
keorn 2020-03-21 14:41:56 +01:00 committed by GitHub
parent 2702dc6654
commit c50a5bf123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,6 +52,14 @@ function tex(plt::Plot, fn::AbstractString)
end end
tex(fn::AbstractString) = tex(current(), fn) tex(fn::AbstractString) = tex(current(), fn)
function json(plt::Plot, fn::AbstractString)
fn = addExtension(fn, "json")
io = open(fn, "w")
show(io, MIME("application/vnd.plotly.v1+json"), plt)
close(io)
end
json(fn::AbstractString) = json(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")
@ -78,6 +86,7 @@ const _savemap = Dict(
"ps" => ps, "ps" => ps,
"eps" => eps, "eps" => eps,
"tex" => tex, "tex" => tex,
"json" => json,
"html" => html, "html" => html,
"tikz" => tex, "tikz" => tex,
"txt" => txt, "txt" => txt,