Skip to content

Commit

Permalink
bring all show() methods together
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Stukalov committed Dec 13, 2024
1 parent 4c2f604 commit 9acc534
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ function Base.show(io::IO, mm::MIME"text/html", p::SyncPlot)
end
Base.show(io::IO, mm::MIME"application/prs.juno.plotpane+html", p::SyncPlot) = show(io, mm, p.scope)

# using @eval instead of Union{} to avoid ambiguity with other methods
for mime in [MIME"text/plain", MIME"application/vnd.plotly.v1+json", MIME"application/prs.juno.plotpane+html"]
@eval Base.show(io::IO, mm::$mime, p::SyncPlot, args...; kwargs...) = show(io, mm, p.plot, args...; kwargs...)
end

function SyncPlot(
p::Plot;
kwargs...
Expand Down Expand Up @@ -343,11 +348,4 @@ for f in (:extendtraces!, :prependtraces!)
end
end


for mime in ["text/plain", "application/vnd.plotly.v1+json", "application/prs.juno.plotpane+html"]
function Base.show(io::IO, m::MIME{Symbol(mime)}, p::SyncPlot, args...)
show(io, m, p.plot, args...)
end
end

PlotlyBase.savejson(sp::SyncPlot, fn::String) = PlotlyBase.savejson(sp.plot, fn)

0 comments on commit 9acc534

Please sign in to comment.