Skip to content

Commit

Permalink
Merge befbaca into b17039e
Browse files Browse the repository at this point in the history
  • Loading branch information
davidanthoff committed Nov 17, 2017
2 parents b17039e + befbaca commit 9fdce31
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ os:
- linux
- osx
julia:
- 0.5
- 0.6
notifications:
email: false
Expand Down
5 changes: 4 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
julia 0.5
julia 0.6
Compat 0.9.1
JSON
Requires
NodeJS
Cairo
Rsvg
IteratorInterfaceExtensions 0.0.1
TableTraits 0.0.2
IterableTables
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"

Expand Down
31 changes: 15 additions & 16 deletions src/VegaLite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ VERSION >= v"0.4" && __precompile__()
module VegaLite

using JSON, Compat, Requires, NodeJS, Cairo, Rsvg
import IteratorInterfaceExtensions, TableTraits
# using PhantomJS

# import Base: show
import Base: display, REPL.REPLDisplay
import Base: |>

# This import can eventually be removed, it currently just makes sure
# that the iterable tables integration for DataFrames and friends
# is loaded
import IterableTables

export renderer, actionlinks, junoplotpane, png, svg, jgp, pdf, savefig


Expand Down Expand Up @@ -82,29 +88,22 @@ include("juno_integration.jl")
include("io.jl")
include("show.jl")

### TableTraits.jl integration

######################## conditional definitions #######################
function vldata(d)
TableTraits.isiterabletable(d) || error("Only iterable tables can be passed to vldata.")

### Integration with DataFrames
@require DataFrames begin
function vldata(d::DataFrames.DataFrame)
recs = [ Dict(r) for r in DataFrames.eachrow(d) ]
VegaLite.VLSpec{:data}(Dict("values" => recs))
end
it = IteratorInterfaceExtensions.getiterator(d)

|>(a::DataFrames.DataFrame, b::VLSpec) = vldata(a) |> b
end
recs = [Dict(c[1]=>isnull(c[2]) ? nothing : get(c[2]) for c in zip(keys(r), values(r))) for r in it ]

### Integration with DataTables
@require DataTables begin
function vldata(d::DataTables.DataTable)
recs = [ Dict(r) for r in DataTables.eachrow(d) ]
VegaLite.VLSpec{:data}(Dict("values" => recs))
end

|>(a::DataTables.DataTable, b::VLSpec) = vldata(a) |> b
end

|>(a, b::VLSpec) = vldata(a) |> b

######################## conditional definitions #######################

### Integration with Juno
include("juno_integration.jl")

Expand Down

0 comments on commit 9fdce31

Please sign in to comment.