Atom: add back PLOTS_USE_ATOM_PLOTPANE; initialize backend when backend is set and removed the println
This commit is contained in:
parent
966dede6e8
commit
576ed7b7b3
@ -152,8 +152,8 @@ function backend()
|
|||||||
sym = CURRENT_BACKEND.sym
|
sym = CURRENT_BACKEND.sym
|
||||||
if !(sym in _initialized_backends)
|
if !(sym in _initialized_backends)
|
||||||
|
|
||||||
# initialize
|
# # initialize
|
||||||
println("[Plots.jl] Initializing backend: ", sym)
|
# println("[Plots.jl] Initializing backend: ", sym)
|
||||||
|
|
||||||
inst = _backend_instance(sym)
|
inst = _backend_instance(sym)
|
||||||
try
|
try
|
||||||
@ -176,12 +176,14 @@ function backend(pkg::AbstractBackend)
|
|||||||
CURRENT_BACKEND.sym = backend_name(pkg)
|
CURRENT_BACKEND.sym = backend_name(pkg)
|
||||||
warn_on_deprecated_backend(CURRENT_BACKEND.sym)
|
warn_on_deprecated_backend(CURRENT_BACKEND.sym)
|
||||||
CURRENT_BACKEND.pkg = pkg
|
CURRENT_BACKEND.pkg = pkg
|
||||||
|
backend()
|
||||||
end
|
end
|
||||||
|
|
||||||
function backend(modname::Symbol)
|
function backend(modname::Symbol)
|
||||||
warn_on_deprecated_backend(modname)
|
warn_on_deprecated_backend(modname)
|
||||||
CURRENT_BACKEND.sym = modname
|
CURRENT_BACKEND.sym = modname
|
||||||
CURRENT_BACKEND.pkg = _backend_instance(modname)
|
CURRENT_BACKEND.pkg = _backend_instance(modname)
|
||||||
|
backend()
|
||||||
end
|
end
|
||||||
|
|
||||||
const _deprecated_backends = [:qwt, :winston, :bokeh, :gadfly, :immerse]
|
const _deprecated_backends = [:qwt, :winston, :bokeh, :gadfly, :immerse]
|
||||||
|
|||||||
@ -251,53 +251,41 @@ end
|
|||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
function setup_atom()
|
function setup_atom()
|
||||||
# @require Atom begin
|
|
||||||
if isatom()
|
if isatom()
|
||||||
# @eval import Atom, Media
|
|
||||||
@eval import Atom, Media
|
@eval import Atom, Media
|
||||||
Media.media(Plot, Media.Plot)
|
Media.media(Plot, Media.Plot)
|
||||||
|
|
||||||
# default text/plain passes to html
|
# default text/plain so it doesn't complain
|
||||||
@eval function Base.show{B}(io::IO, m::MIME{Symbol("text/plain")}, plt::Plot{B})
|
function Base.show{B}(io::IO, ::MIME"text/plain", plt::Plot{B})
|
||||||
# show(io, MIME("text/html"), plt)
|
|
||||||
print(io, "Plot{$B}()")
|
print(io, "Plot{$B}()")
|
||||||
end
|
end
|
||||||
|
|
||||||
# for inline values, display the plot (gui) and return a graph icon
|
function Media.render(::Atom.Inline, plt::Plot)
|
||||||
function Atom.Media.render(::Atom.Inline, plt::Plot)
|
|
||||||
# # info("using Media.render")
|
|
||||||
# display(plt)
|
|
||||||
# Media.render(Atom.icon("graph"))
|
|
||||||
# Media.render(Atom.PlotPane(), plt)
|
|
||||||
nothing
|
nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
# if get(ENV, "PLOTS_USE_ATOM_PLOTPANE", false) in (true, 1, "1", "true", "yes")
|
if get(ENV, "PLOTS_USE_ATOM_PLOTPANE", true) in (true, 1, "1", "true", "yes")
|
||||||
|
# this is like "display"... sends an html div with the plot to the PlotPane
|
||||||
# # # connects the render function
|
function Media.render(pane::Atom.PlotPane, plt::Plot)
|
||||||
# # for T in (GadflyBackend,ImmerseBackend,PyPlotBackend,GRBackend)
|
Media.render(pane, Atom.div(Atom.d(), Atom.HTML(stringmime(MIME("text/html"), plt))))
|
||||||
# # Atom.Media.media(Plot{T}, Atom.Media.Plot)
|
end
|
||||||
# # end
|
else
|
||||||
# Atom.Media.media(Plot, Atom.Media.Graphical)
|
#
|
||||||
# # Atom.Media.media{T <: Union{GadflyBackend,ImmerseBackend,PyPlotBackend,GRBackend}}(Plot{T}, Atom.Media.Plot)
|
function Media.render(pane::Atom.PlotPane, plt::Plot)
|
||||||
|
display(Plots.PlotsDisplay(), plt)
|
||||||
# # Atom.displaysize(::Plot) = (535, 379)
|
s = "PlotPane turned off. Unset ENV[\"PLOTS_USE_ATOM_PLOTPANE\"] and restart Julia to enable it."
|
||||||
# # Atom.displaytitle(plt::Plot) = "Plots.jl (backend: $(backend(plt)))"
|
Media.render(pane, Atom.div(Atom.d(), Atom.HTML(s)))
|
||||||
|
end
|
||||||
# this is like "display"... sends an html div with the plot to the PlotPane
|
|
||||||
function Media.render(pane::Atom.PlotPane, plt::Plot)
|
|
||||||
Media.render(pane, Atom.div(Atom.d(), Atom.HTML(stringmime(MIME("text/html"), plt))))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# # # force text/plain to output to the PlotPane
|
# Atom.displaysize(::Plot) = (535, 379)
|
||||||
# # function Base.show(io::IO, ::MIME"text/plain", plt::Plot)
|
# Atom.displaytitle(plt::Plot) = "Plots.jl (backend: $(backend(plt)))"
|
||||||
# # # show(io::IO, MIME("text/html"), plt)
|
|
||||||
# # Atom.Media.render(pane)
|
|
||||||
# # end
|
|
||||||
|
|
||||||
# # function Atom.Media.render(pane::Atom.PlotPane, plt::Plot{PlotlyBackend})
|
# special handling for plotly/plotlyjs
|
||||||
# # html = Media.render(pane, Atom.div(Atom.d(), Atom.HTML(stringmime(MIME("text/html"), plt))))
|
function Media.render{B<:Union{PlotlyBackend,PlotlyJSBackend}}(pane::Atom.PlotPane, plt::Plot{B})
|
||||||
# # end
|
display(Plots.PlotsDisplay(), plt)
|
||||||
# end
|
s = "PlotPane turned off. The plotly and plotlyjs backends cannot render in the PlotPane due to javascript issues."
|
||||||
|
Media.render(pane, Atom.div(Atom.d(), Atom.HTML(s)))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user