diff --git a/.travis.yml b/.travis.yml index c0c57b42..84bd65ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ os: - linux - osx julia: - - 0.5 - 0.6 notifications: email: false diff --git a/REQUIRE b/REQUIRE index 74fce839..33ac720b 100644 --- a/REQUIRE +++ b/REQUIRE @@ -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 diff --git a/appveyor.yml b/appveyor.yml index 7d33adeb..3e8b9d9b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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" diff --git a/src/VegaLite.jl b/src/VegaLite.jl index 3db89c85..06b6907a 100644 --- a/src/VegaLite.jl +++ b/src/VegaLite.jl @@ -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 @@ -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")