fixed dataframes loading; added dataframes to tests; started atom integration

This commit is contained in:
Thomas Breloff 2016-03-11 13:07:25 -05:00
parent b08212e2f9
commit 8b2a838388
5 changed files with 57 additions and 34 deletions

View File

@ -239,6 +239,9 @@ function __init__()
@eval import IJulia @eval import IJulia
IJulia.display_dict(plt::AbstractPlot) = Dict{ASCIIString, ByteString}("text/html" => sprint(writemime, "text/html", plt)) IJulia.display_dict(plt::AbstractPlot) = Dict{ASCIIString, ByteString}("text/html" => sprint(writemime, "text/html", plt))
end end
setup_dataframes()
setup_atom()
end end
# --------------------------------------------------------- # ---------------------------------------------------------

View File

@ -117,3 +117,25 @@ Base.display(::Base.REPL.REPLDisplay, ::MIME"text/plain", plt::AbstractPlot) = g
function Base.writemime(io::IO, ::MIME"text/html", plt::AbstractPlot) function Base.writemime(io::IO, ::MIME"text/html", plt::AbstractPlot)
writemime(io, MIME("image/svg+xml"), plt) writemime(io, MIME("image/svg+xml"), plt)
end end
# ---------------------------------------------------------
# Atom PlotPane
# ---------------------------------------------------------
function setup_atom()
# @require Atom begin
# @eval begin
# import Atom
#
# Atom.displaysize(::AbstractPlot) = (535, 379)
# Atom.displaytitle(::AbstractPlot) = "Plots.jl"
#
# Atom.@render Atom.PlotPane p::Plot begin
# x, y = Atom.@rpc Atom.plotsize()
# plot!(p, size=(x,y)) # changes the size of the Plots.Plot
# Atom.div(Dict(:style=>"background: white"), Atom.HTML(stringmime("text/html", p)))
# end
# end
# end
end

View File

@ -531,6 +531,7 @@ end
# For DataFrame support. Imports DataFrames and defines the necessary methods which support them. # For DataFrame support. Imports DataFrames and defines the necessary methods which support them.
function setup_dataframes()
@require DataFrames begin @require DataFrames begin
function createKWargsList(plt::AbstractPlot, df::DataFrames.AbstractDataFrame, args...; kw...) function createKWargsList(plt::AbstractPlot, df::DataFrames.AbstractDataFrame, args...; kw...)
@ -547,23 +548,16 @@ end
end end
function getDataFrameFromKW(d::Dict) function getDataFrameFromKW(d::Dict)
# for (k,v) in kw
# if k == :dataframe
# return v
# end
# end
get(d, :dataframe) do get(d, :dataframe) do
error("Missing dataframe argument!") error("Missing dataframe argument!")
end end
end end
# the conversion functions for when we pass symbols or vectors of symbols to reference dataframes # the conversion functions for when we pass symbols or vectors of symbols to reference dataframes
# convertToAnyVector(s::Symbol; kw...) = Any[getDataFrameFromKW(;kw...)[s]], s
# convertToAnyVector(v::AVec{Symbol}; kw...) = (df = getDataFrameFromKW(;kw...); Any[df[s] for s in v]), v
convertToAnyVector(s::Symbol, d::Dict) = Any[getDataFrameFromKW(d)[s]], s convertToAnyVector(s::Symbol, d::Dict) = Any[getDataFrameFromKW(d)[s]], s
convertToAnyVector(v::AVec{Symbol}, d::Dict) = (df = getDataFrameFromKW(d); Any[df[s] for s in v]), v convertToAnyVector(v::AVec{Symbol}, d::Dict) = (df = getDataFrameFromKW(d); Any[df[s] for s in v]), v
end end
end
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -10,3 +10,5 @@ ImageMagick
PyPlot PyPlot
@osx QuartzImageIO @osx QuartzImageIO
GR GR
DataFrames
RDatasets

View File

@ -2,6 +2,8 @@
using VisualRegressionTests using VisualRegressionTests
using ExamplePlots using ExamplePlots
import DataFrames, RDatasets
# don't let pyplot use a gui... it'll crash # don't let pyplot use a gui... it'll crash
# note: Agg will set gui -> :none in PyPlot # note: Agg will set gui -> :none in PyPlot
ENV["MPLBACKEND"] = "Agg" ENV["MPLBACKEND"] = "Agg"