Merge pull request #2997 from daschw/plotlybase

Replace ORCA with Plotlybase
This commit is contained in:
Daniel Schwabeneder 2020-09-21 21:35:07 +02:00 committed by GitHub
commit 11f3715453
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

View File

@ -367,10 +367,10 @@ is_marker_supported(::GRBackend, shape::Shape) = true
function _initialize_backend(pkg::PlotlyBackend) function _initialize_backend(pkg::PlotlyBackend)
try try
@eval Main begin @eval Main begin
import ORCA import PlotlyBase
end end
catch catch
@info "For saving to png with the Plotly backend ORCA has to be installed." @info "For saving to png with the Plotly backend PlotlyBase has to be installed."
end end
end end
@ -488,7 +488,7 @@ const _pgfplots_scale = [:identity, :ln, :log2, :log10]
function _initialize_backend(pkg::PlotlyJSBackend) function _initialize_backend(pkg::PlotlyJSBackend)
@eval Main begin @eval Main begin
import PlotlyJS, ORCA import PlotlyJS
export PlotlyJS export PlotlyJS
end end
end end

View File

@ -1,14 +1,14 @@
function plotlybase_syncplot(plt::Plot) function plotlybase_syncplot(plt::Plot)
plt.o = ORCA.PlotlyBase.Plot() plt.o = PlotlyBase.Plot()
traces = ORCA.PlotlyBase.GenericTrace[] traces = PlotlyBase.GenericTrace[]
for series_dict in plotly_series(plt) for series_dict in plotly_series(plt)
plotly_type = pop!(series_dict, :type) plotly_type = pop!(series_dict, :type)
push!(traces, ORCA.PlotlyBase.GenericTrace(plotly_type; series_dict...)) push!(traces, PlotlyBase.GenericTrace(plotly_type; series_dict...))
end end
ORCA.PlotlyBase.addtraces!(plt.o, traces...) PlotlyBase.addtraces!(plt.o, traces...)
layout = plotly_layout(plt) layout = plotly_layout(plt)
w, h = plt[:size] w, h = plt[:size]
ORCA.PlotlyBase.relayout!(plt.o, layout, width = w, height = h) PlotlyBase.relayout!(plt.o, layout, width = w, height = h)
return plt.o return plt.o
end end
@ -19,5 +19,5 @@ for (mime, fmt) in (
"image/eps" => "eps", "image/eps" => "eps",
) )
@eval _show(io::IO, ::MIME{Symbol($mime)}, plt::Plot{PlotlyBackend}) = @eval _show(io::IO, ::MIME{Symbol($mime)}, plt::Plot{PlotlyBackend}) =
ORCA.PlotlyBase.savefig(io, plotlybase_syncplot(plt), format = $fmt) PlotlyBase.savefig(io, plotlybase_syncplot(plt), format = $fmt)
end end

View File

@ -41,8 +41,8 @@ function __init__()
include(fn) include(fn)
end end
@require ORCA = "47be7bcc-f1a6-5447-8b36-7eeeff7534fd" begin @require PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5" begin
fn = joinpath(@__DIR__, "backends", "orca.jl") fn = joinpath(@__DIR__, "backends", "plotlybase.jl")
include(fn) include(fn)
end end