Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions KomaMRIPlots/src/ui/PlotBackends.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Available backends for plots
const PLOT_BACKENDS = ("PlotlyJS", "PlutoPlotly")
const PLOT_BACKENDS = ("PlotlyJS", "PlotlyBase", "PlutoPlotly")
const PLOT_BACKEND = Ref{String}("PlotlyJS")

# Choose plot backend
Expand All @@ -25,11 +25,13 @@ end
function plot_koma(args...; kwargs...)
if PLOT_BACKEND[] == "PlotlyJS"
plot_koma(KomaPlotlyJSBackend(), args...; kwargs...)
elseif PLOT_BACKEND[] == "PlotlyBase"
plot_koma(KomaPlotlyBaseBackend(), args...; kwargs...)
elseif PLOT_BACKEND[] == "PlutoPlotly"
plot_koma(KomaPlutoPlotlyBackend(), args...; kwargs...)
else
error("""
Unsupported KomaMRIPlots backend: $PLOT_BACKEND.
Unsupported KomaMRIPlots backend: $(PLOT_BACKEND[]).
Supported backends are: $PLOT_BACKENDS.
""")
end
Expand All @@ -41,6 +43,12 @@ function plot_koma(::KomaPlotlyJSBackend, args...; kwargs...)
return PlotlyJS.plot(args...; kwargs...)
end

# PlotlyBase (For Google Colab / Jupyter)
struct KomaPlotlyBaseBackend end
function plot_koma(::KomaPlotlyBaseBackend, args...; kwargs...)
return PlotlyJS.PlotlyBase.Plot(args...; kwargs...)
end

# PlutoPlotly
struct KomaPlutoPlotlyBackend end
const PLUTOPLOTLY_LOADED = Ref{Bool}(false)
Expand All @@ -56,4 +64,4 @@ function plot_koma(::KomaPlutoPlotlyBackend, args...; kwargs...)
return nothing
end
end
function _plutoplotly_plot end
function _plutoplotly_plot end