atom fix; add_backend for pyplot/plotly/plotlyjs; closes #449

This commit is contained in:
Thomas Breloff 2016-08-17 16:45:40 -04:00
parent 959da6c5ae
commit 60c8f6f578
6 changed files with 35 additions and 1 deletions

View File

@ -69,6 +69,7 @@ export
backend,
backends,
backend_name,
add_backend,
aliases,
dataframes,

View File

@ -44,6 +44,9 @@ include("backends/web.jl")
# ---------------------------------------------------------
add_backend(pkg::Symbol) = add_backend(_backend_instance(pkg))
add_backend(b::AbstractBackend) = warn("No custom install defined for $(backend_name(b))")
# don't do anything as a default
_create_backend_figure(plt::Plot) = nothing
_prepare_plot_object(plt::Plot) = nothing

View File

@ -47,6 +47,11 @@ is_string_supported(::PlotlyBackend) = true
# --------------------------------------------------------------------------------------
function add_backend(::PlotlyBackend)
Pkg.build("Plots")
end
const _plotly_js_path = joinpath(dirname(@__FILE__), "..", "..", "deps", "plotly-latest.min.js")
function _initialize_backend(::PlotlyBackend; kw...)

View File

@ -11,6 +11,17 @@ is_string_supported(::PlotlyJSBackend) = true
# --------------------------------------------------------------------------------------
function add_backend(::PlotlyJSBackend)
if !is_installed("PlotlyJS")
Pkg.add("PlotlyJS")
@eval import Blink
Blink.AtomShell.install()
Pkg.add("Rsvg")
end
end
function _initialize_backend(::PlotlyJSBackend; kw...)
@eval begin
import PlotlyJS

View File

@ -47,6 +47,14 @@ is_subplot_supported(::PyPlotBackend) = true
# --------------------------------------------------------------------------------------
function add_backend(::PyPlotBackend)
if !is_installed("PyPlot")
withenv("PYTHON" => "") do
Pkg.add("PyPlot")
Pkg.build("PyPlot")
end
end
end
function _initialize_backend(::PyPlotBackend)
@eval begin

View File

@ -255,9 +255,15 @@ function setup_atom()
# @eval import Atom, Media
@eval import Atom
# default text/plain passes to html... handles Interact issues
function Base.show(io::IO, m::MIME"text/plain", plt::Plot)
show(io, MIME("text/html"), plt)
end
# for inline values, display the plot (gui) and return a graph icon
function Atom.Media.render(::Atom.Inline, plt::Plot)
display(PlotsDisplay(), plt)
# info("using Media.render")
display(plt)
Atom.icon("graph")
end