From abdcb128d5d96ecb17724a495d876398938646ed Mon Sep 17 00:00:00 2001 From: davidanthoff Date: Tue, 26 Jul 2022 19:48:35 +0000 Subject: [PATCH] Format files using DocumentFormat --- docs/make.jl | 46 +++--- src/Vega.jl | 2 +- .../dsl_vlplot_function.jl | 6 +- src/dsl_vlplot_macro/dsl_vlplot_macro.jl | 10 +- src/rendering/io.jl | 4 +- src/rendering/render.jl | 143 ++++++++++-------- src/rendering/to_julia.jl | 48 +++--- src/spec_utils.jl | 6 +- test/runtests.jl | 14 +- test/test_config.jl | 18 +-- test/test_io.jl | 82 +++++----- test/test_macro.jl | 60 ++++---- test/test_properties.jl | 10 +- test/test_show.jl | 14 +- test/test_vg.jl | 60 ++++---- 15 files changed, 265 insertions(+), 258 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 510496b..7fde57c 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -9,30 +9,28 @@ function Base.show(io::IO, m::MIME"text/html", v::Vega.VGSpec) end makedocs( - modules=[Vega], - sitename="Vega.jl", - pages=[ - "Home" => "index.md", - "Getting Started" => Any[ - "Installation" => "gettingstarted/installation.md" - ], - "User Guide" => Any[ - "Using Vega" => "userguide/vega.md" - ], - "Examples" => Any[ - - "Line & Area Charts" => "examples/examples_vega_line_area_charts.md", - "Circular Charts" => "examples/examples_vega_circular_charts.md", - "Scatter Plots" => "examples/examples_vega_scatter_plots.md", - "Tree Diagrams" => "examples/examples_vega_tree_diagrams.md", - "Network Diagrams" => "examples/examples_vega_network_diagrams.md", - "Single Data Source" => "examples/examples_vega_single_data_source.md", - "Multiple Data Source" => "examples/examples_vega_multi_data_source.md" - ], - "Reference Manual" => [ - "Global settings" => "referencemanual/global.md", - "Outputs" => "referencemanual/output.md"] - ] + modules=[Vega], + sitename="Vega.jl", + pages=[ + "Home" => "index.md", + "Getting Started" => Any[ + "Installation"=>"gettingstarted/installation.md" + ], + "User Guide" => Any[ + "Using Vega"=>"userguide/vega.md" + ], + "Examples" => Any["Line & Area Charts"=>"examples/examples_vega_line_area_charts.md", + "Circular Charts"=>"examples/examples_vega_circular_charts.md", + "Scatter Plots"=>"examples/examples_vega_scatter_plots.md", + "Tree Diagrams"=>"examples/examples_vega_tree_diagrams.md", + "Network Diagrams"=>"examples/examples_vega_network_diagrams.md", + "Single Data Source"=>"examples/examples_vega_single_data_source.md", + "Multiple Data Source"=>"examples/examples_vega_multi_data_source.md" + ], + "Reference Manual" => [ + "Global settings" => "referencemanual/global.md", + "Outputs" => "referencemanual/output.md"] + ] ) deploydocs( diff --git a/src/Vega.jl b/src/Vega.jl index 825b76c..085fd8e 100644 --- a/src/Vega.jl +++ b/src/Vega.jl @@ -62,7 +62,7 @@ show if plots will have (true) or not (false) the action links displayed indicate if actions links should be dislpayed under the plot """ actionlinks() = ACTIONSLINKS -actionlinks(b::Bool) = (global ACTIONSLINKS ; ACTIONSLINKS = b) +actionlinks(b::Bool) = (global ACTIONSLINKS; ACTIONSLINKS = b) ######################## includes ##################################### diff --git a/src/dsl_vlplot_function/dsl_vlplot_function.jl b/src/dsl_vlplot_function/dsl_vlplot_function.jl index 7dc45b3..36b7603 100644 --- a/src/dsl_vlplot_function/dsl_vlplot_function.jl +++ b/src/dsl_vlplot_function/dsl_vlplot_function.jl @@ -19,7 +19,7 @@ function convert_nt_to_dict(item::AbstractVegaFragment, fragtype) return fragtype(item.positional, OrderedDict{String,Any}(string(k) => convert_nt_to_dict(v, fragtype) for (k, v) in pairs(item.named))) end -function walk_dict(f, d::T, parent) where {T <: AbstractDict} +function walk_dict(f, d::T, parent) where {T<:AbstractDict} res = T() for p in d if p[2] isa Dict @@ -108,6 +108,6 @@ function convert_frag_tree_to_dict(spec::VGFrag) return OrderedDict{String,Any}(k => replace_remaining_frag(v) for (k, v) in spec.named) end -function vgplot(args...;kwargs...) - return VGSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec(vgfrag(args...;kwargs...)))) +function vgplot(args...; kwargs...) + return VGSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec(vgfrag(args...; kwargs...)))) end diff --git a/src/dsl_vlplot_macro/dsl_vlplot_macro.jl b/src/dsl_vlplot_macro/dsl_vlplot_macro.jl index 27f12d3..719396d 100644 --- a/src/dsl_vlplot_macro/dsl_vlplot_macro.jl +++ b/src/dsl_vlplot_macro/dsl_vlplot_macro.jl @@ -3,7 +3,7 @@ function convert_curly_style_array(exprs, fragtype) for ex in exprs if ex isa Expr && ex.head == :braces - push!(res.args, :( $(convert_curly_style(ex.args, fragtype)) )) + push!(res.args, :($(convert_curly_style(ex.args, fragtype)))) else push!(res.args, esc(ex)) end @@ -21,11 +21,11 @@ function convert_curly_style(exprs, fragtype) for ex in exprs if ex isa Expr && ex.head == :(=) if ex.args[2] isa Expr && ex.args[2].head == :braces - push!(named_args, :( $(string(ex.args[1])) => $(convert_curly_style(ex.args[2].args, fragtype)) )) + push!(named_args, :($(string(ex.args[1])) => $(convert_curly_style(ex.args[2].args, fragtype)))) elseif ex.args[2] isa Expr && ex.args[2].head == :vect - push!(named_args, :( $(string(ex.args[1])) => $(convert_curly_style_array(ex.args[2].args, fragtype)) )) + push!(named_args, :($(string(ex.args[1])) => $(convert_curly_style_array(ex.args[2].args, fragtype)))) else - push!(named_args, :( $(string(ex.args[1])) => $(esc(ex.args[2])) )) + push!(named_args, :($(string(ex.args[1])) => $(esc(ex.args[2])))) end elseif ex isa Expr && ex.head == :braces push!(pos_args, convert_curly_style(ex.args, fragtype)) @@ -40,7 +40,7 @@ end macro vgplot(ex...) new_ex = convert_curly_style(ex, VGFrag) - return :( Vega.VGSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec($new_ex))) ) + return :(Vega.VGSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec($new_ex)))) end macro vgfrag(ex...) diff --git a/src/rendering/io.jl b/src/rendering/io.jl index 10b3cb7..2ae688c 100644 --- a/src/rendering/io.jl +++ b/src/rendering/io.jl @@ -40,5 +40,5 @@ end savespec(filename::AbstractString, v::AbstractVegaSpec; kwargs...) = open(filename, "w") do io - savespec(io, v; kwargs...) -end + savespec(io, v; kwargs...) + end diff --git a/src/rendering/render.jl b/src/rendering/render.jl index 9799277..90056f9 100644 --- a/src/rendering/render.jl +++ b/src/rendering/render.jl @@ -16,47 +16,50 @@ function writehtml_full(io::IO, spec::VGSpec; title="Vega plot") divid = "vg" * randstring(3) println(io, - """ - - - $title - - - - - -
- - - - - + + + +
+ + + + + + - - """) + +""" + ) end function writehtml_full(spec::VGSpec; title="Vega plot") @@ -74,35 +77,41 @@ Creates a HTML script + div block for showing the plot (typically for Pluto). VegaLite js files are loaded from the web using script tags. """ function writehtml_partial_script(io::IO, spec::VGSpec; title="VegaLite plot") - divid = "vg" * randstring(3) - print(io, """ - - - - - -
- - - """) + divid = "vg" * randstring(3) + print( + io, + """ + + + + + +
+ + +""" + ) end @@ -113,9 +122,9 @@ function launch_browser(tmppath::String) if Sys.isapple() run(`open $tmppath`) elseif Sys.iswindows() - run(`cmd /c start $tmppath`) - elseif Sys.islinux() - run(`xdg-open $tmppath`) + run(`cmd /c start $tmppath`) + elseif Sys.islinux() + run(`xdg-open $tmppath`) end end diff --git a/src/rendering/to_julia.jl b/src/rendering/to_julia.jl index 9e52be7..5c8a5da 100644 --- a/src/rendering/to_julia.jl +++ b/src/rendering/to_julia.jl @@ -2,11 +2,11 @@ function print_datavaluesnode_as_julia(io, it, col_names) print(io, "[") for (row_index, row) in enumerate(it) - row_index==1 || print(io, ",") + row_index == 1 || print(io, ",") print(io, "{") for (col_index, col_value) in enumerate(row) - col_index==1 || print(io, ",") + col_index == 1 || print(io, ",") print(io, col_names[col_index]) print(io, "=") print(io, col_value isa DataValue ? get(col_value, nothing) : col_value) @@ -22,66 +22,66 @@ function print_vspec_as_julia(io::IO, d::DataValuesNode, indent, indent_level, n col_names = collect(keys(d.columns)) it = TableTraitsUtils.create_tableiterator(collect(values(d.columns)), col_names) - if include_data==:short + if include_data == :short print(io, "...") else print_datavaluesnode_as_julia(io, it, col_names) end end -function print_vspec_as_julia(io::IO, vect::AbstractVector, indent, indent_level, newlines, include_data) - for (i,v) in enumerate(vect) - i>1 && print(io, ",", newlines ? "\n" : "") +function print_vspec_as_julia(io::IO, vect::AbstractVector, indent, indent_level, newlines, include_data) + for (i, v) in enumerate(vect) + i > 1 && print(io, ",", newlines ? "\n" : "") if v isa AbstractDict - print(io, " "^(indent*indent_level), "{") + print(io, " "^(indent * indent_level), "{") newlines && println(io) - print_vspec_as_julia(io, v, indent, indent_level+1, newlines, include_data) + print_vspec_as_julia(io, v, indent, indent_level + 1, newlines, include_data) newlines && println(io) - print(io, " "^(indent*indent_level), "}") + print(io, " "^(indent * indent_level), "}") elseif v isa AbstractVector print(io, "[") newlines && println(io) - print_vspec_as_julia(io, v, indent, indent_level+1, newlines, include_data) + print_vspec_as_julia(io, v, indent, indent_level + 1, newlines, include_data) newlines && println(io) - print(io, " "^(indent*indent_level), "]") + print(io, " "^(indent * indent_level), "]") elseif v isa DataValuesNode print_vspec_as_julia(io, v, indent, indent_level, newlines, include_data) elseif v isa AbstractString || v isa Symbol - print(io, " "^(indent*indent_level)) + print(io, " "^(indent * indent_level)) print(io, "\"") print(io, string(v)) print(io, "\"") else - print(io, " "^(indent*indent_level)) + print(io, " "^(indent * indent_level)) print(io, v) end end end function print_vspec_as_julia(io::IO, dict::AbstractDict, indent, indent_level, newlines, include_data) - dict = (include_data==:short || include_data) ? dict : OrderedDict{String,Any}(i for i in dict if i[1]!="data") - for (i,(k,v)) in enumerate(dict) - i>1 && print(io, ",", newlines ? "\n" : "") - print(io, " "^(indent*indent_level), k) + dict = (include_data == :short || include_data) ? dict : OrderedDict{String,Any}(i for i in dict if i[1] != "data") + for (i, (k, v)) in enumerate(dict) + i > 1 && print(io, ",", newlines ? "\n" : "") + print(io, " "^(indent * indent_level), k) print(io, "=") if v isa AbstractDict print(io, "{") newlines && println(io) - print_vspec_as_julia(io, v, indent, indent_level+1, newlines, include_data) + print_vspec_as_julia(io, v, indent, indent_level + 1, newlines, include_data) newlines && println(io) - print(io, " "^(indent*indent_level), "}") + print(io, " "^(indent * indent_level), "}") elseif v isa AbstractVector print(io, "[") newlines && println(io) - print_vspec_as_julia(io, v, indent, indent_level+1, newlines, include_data) + print_vspec_as_julia(io, v, indent, indent_level + 1, newlines, include_data) newlines && println(io) - print(io, " "^(indent*indent_level), "]") + print(io, " "^(indent * indent_level), "]") elseif v isa AbstractString || v isa Symbol print(io, "\"") print(io, string(v)) print(io, "\"") elseif v isa DataValuesNode - print_vspec_as_julia(io, v, indent, indent_level+1, newlines, include_data) + print_vspec_as_julia(io, v, indent, indent_level + 1, newlines, include_data) else print(io, v) end @@ -100,8 +100,8 @@ in the output. `indent` controls whether the code is printed in one line function printrep end function printrepr(io::IO, v::VGSpec; indent=nothing, include_data=false) - newlines = indent===nothing ? false : true - indent = indent===nothing ? 0 : indent + newlines = indent === nothing ? false : true + indent = indent === nothing ? 0 : indent print(io, "@vgplot(") newlines && println(io) diff --git a/src/spec_utils.jl b/src/spec_utils.jl index 5188fe2..53735f5 100644 --- a/src/spec_utils.jl +++ b/src/spec_utils.jl @@ -4,7 +4,7 @@ end abstract type AbstractVegaSpec end -Base.copy(spec::T) where {T <: AbstractVegaSpec} = T(copy(getparams(spec))) +Base.copy(spec::T) where {T<:AbstractVegaSpec} = T(copy(getparams(spec))) const ObjectLike = Union{AbstractVegaSpec,ObjectProxy} @@ -51,11 +51,11 @@ struct DataValuesNode function DataValuesNode(it) col_values, col_names = TableTraitsUtils.create_columns_from_iterabletable(it) - + return new(OrderedDict{Symbol,AbstractVector}(i[1] => i[2] for i in zip(col_names, col_values))) end end - + Base.:(==)(a::DataValuesNode, b::DataValuesNode) = a.columns == b.columns function our_show_json(io, it, col_names) diff --git a/test/runtests.jl b/test/runtests.jl index b984788..5434a01 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,12 +4,12 @@ using Dates @testset "Vega" begin -include("testhelper_create_vg_plot.jl") -include("test_io.jl") -include("test_show.jl") -include("test_config.jl") -include("test_macro.jl") -include("test_vg.jl") -include("test_properties.jl") + include("testhelper_create_vg_plot.jl") + include("test_io.jl") + include("test_show.jl") + include("test_config.jl") + include("test_macro.jl") + include("test_vg.jl") + include("test_properties.jl") end diff --git a/test/test_config.jl b/test/test_config.jl index 28ec725..23d7b98 100644 --- a/test/test_config.jl +++ b/test/test_config.jl @@ -3,15 +3,15 @@ using Vega @testset "Config" begin -@test isa(renderer(), Symbol) -@test_throws MethodError renderer(456) -@test_throws ErrorException renderer(:abcd) -renderer(:canvas) -@test renderer() == :canvas + @test isa(renderer(), Symbol) + @test_throws MethodError renderer(456) + @test_throws ErrorException renderer(:abcd) + renderer(:canvas) + @test renderer() == :canvas -@test isa(actionlinks(), Bool) -@test_throws MethodError actionlinks(46) -actionlinks(false) -@test actionlinks() == false + @test isa(actionlinks(), Bool) + @test_throws MethodError actionlinks(46) + actionlinks(false) + @test actionlinks() == false end diff --git a/test/test_io.jl b/test/test_io.jl index b99c0ec..830829e 100644 --- a/test/test_io.jl +++ b/test/test_io.jl @@ -1,67 +1,67 @@ using Test using Vega -using Vega:getparams +using Vega: getparams using DataFrames using Dates using FileIO @testset "io" begin -vgp = getvgplot() + vgp = getvgplot() -# @testset "$fmt (indent=$(repr(indent)))" for (fmt, plt) in [ -# (format"vegalite", vlp) -# # (format"vega", vgp) # waiting for FileIO -# ], -# indent in [nothing, 4] + # @testset "$fmt (indent=$(repr(indent)))" for (fmt, plt) in [ + # (format"vegalite", vlp) + # # (format"vega", vgp) # waiting for FileIO + # ], + # indent in [nothing, 4] -# let json = sprint(io -> save(Stream(fmt, io), plt, indent=indent)), -# code = "vg\"\"\"$json\"\"\"" -# @test getparams(include_string(@__MODULE__, code)) == getparams(plt) -# end + # let json = sprint(io -> save(Stream(fmt, io), plt, indent=indent)), + # code = "vg\"\"\"$json\"\"\"" + # @test getparams(include_string(@__MODULE__, code)) == getparams(plt) + # end -# let io = IOBuffer() -# save(Stream(fmt, io), plt, indent=indent) -# seek(io, 0) -# @test getparams(load(Stream(fmt, io))) == getparams(plt) -# end + # let io = IOBuffer() + # save(Stream(fmt, io), plt, indent=indent) + # seek(io, 0) + # @test getparams(load(Stream(fmt, io))) == getparams(plt) + # end -# let code = repr("text/plain", plt, context=:compact=>false) -# @test getparams(include_string(@__MODULE__, code)) == getparams(plt) -# end -# end + # let code = repr("text/plain", plt, context=:compact=>false) + # @test getparams(include_string(@__MODULE__, code)) == getparams(plt) + # end + # end -Base.Filesystem.mktempdir() do folder - save(joinpath(folder, "test4.svg"), vgp) - @test isfile(joinpath(folder, "test4.svg")) + Base.Filesystem.mktempdir() do folder + save(joinpath(folder, "test4.svg"), vgp) + @test isfile(joinpath(folder, "test4.svg")) - save(joinpath(folder, "test4.pdf"), vgp) - @test isfile(joinpath(folder, "test4.pdf")) + save(joinpath(folder, "test4.pdf"), vgp) + @test isfile(joinpath(folder, "test4.pdf")) - save(joinpath(folder, "test4.png"), vgp) - @test isfile(joinpath(folder, "test4.png")) + save(joinpath(folder, "test4.png"), vgp) + @test isfile(joinpath(folder, "test4.png")) - # save(joinpath(folder,"test4.eps"), vgp) - # @test isfile(joinpath(folder,"test4.eps")) + # save(joinpath(folder,"test4.eps"), vgp) + # @test isfile(joinpath(folder,"test4.eps")) - vgpl1 = getvgplot() + vgpl1 = getvgplot() - Vega.savespec(joinpath(folder, "test1.vega"), vgpl1, include_data=true) + Vega.savespec(joinpath(folder, "test1.vega"), vgpl1, include_data=true) - vgpl2 = Vega.loadvgspec(joinpath(folder, "test1.vega")) + vgpl2 = Vega.loadvgspec(joinpath(folder, "test1.vega")) - @test vgpl1 == vgpl1 + @test vgpl1 == vgpl1 - # TODO Enable once FileIO stuff is merged - # save(joinpath(folder,"test3.vega"), vgpl1) - # @test isfile(joinpath(folder,"test3.vega")) + # TODO Enable once FileIO stuff is merged + # save(joinpath(folder,"test3.vega"), vgpl1) + # @test isfile(joinpath(folder,"test3.vega")) - # vgpl3 = load(joinpath(folder,"test3.vega")) - # @test isa(vgpl2, VegaLite.VGSpec) + # vgpl3 = load(joinpath(folder,"test3.vega")) + # @test isa(vgpl2, VegaLite.VGSpec) - # save(joinpath(folder,"test4.vega"), vgpl1, include_data=true) - # @test isfile(joinpath(folder,"test4.vega")) + # save(joinpath(folder,"test4.vega"), vgpl1, include_data=true) + # @test isfile(joinpath(folder,"test4.vega")) -end + end end diff --git a/test/test_macro.jl b/test/test_macro.jl index 907edfe..3cf0f80 100644 --- a/test/test_macro.jl +++ b/test/test_macro.jl @@ -1,39 +1,39 @@ using Vega -using Vega:getparams +using Vega: getparams using JSON using Test @testset "macro" begin -spec = vg""" -{ - "data": { - "values": [ - {"a": "A","b": 28}, {"a": "B","b": 55} - ] - }, - "mark": "bar", - "encoding": { - "x": {"field": "a", "type": "ordinal"}, - "y": {"field": "b", "type": "quantitative"} - } -} -""" + spec = vg""" + { + "data": { + "values": [ + {"a": "A","b": 28}, {"a": "B","b": 55} + ] + }, + "mark": "bar", + "encoding": { + "x": {"field": "a", "type": "ordinal"}, + "y": {"field": "b", "type": "quantitative"} + } + } + """ -@test isa(spec, Vega.VGSpec) -@test getparams(spec) == JSON.parse(""" -{ - "data": { - "values": [ - {"a": "A","b": 28}, {"a": "B","b": 55} - ] - }, - "mark": "bar", - "encoding": { - "x": {"field": "a", "type": "ordinal"}, - "y": {"field": "b", "type": "quantitative"} - } -} -""") + @test isa(spec, Vega.VGSpec) + @test getparams(spec) == JSON.parse(""" + { + "data": { + "values": [ + {"a": "A","b": 28}, {"a": "B","b": 55} + ] + }, + "mark": "bar", + "encoding": { + "x": {"field": "a", "type": "ordinal"}, + "y": {"field": "b", "type": "quantitative"} + } + } + """) end diff --git a/test/test_properties.jl b/test/test_properties.jl index 19140a7..6423a7c 100644 --- a/test/test_properties.jl +++ b/test/test_properties.jl @@ -4,10 +4,10 @@ using Setfield @testset "properties" begin -vgp = getvgplot() -@test vgp.width isa Number -@static if VERSION >= v"1.3" - @test vgp.var"$schema" isa String -end + vgp = getvgplot() + @test vgp.width isa Number + @static if VERSION >= v"1.3" + @test vgp.var"$schema" isa String + end end diff --git a/test/test_show.jl b/test/test_show.jl index 2795816..0a82f4e 100644 --- a/test/test_show.jl +++ b/test/test_show.jl @@ -3,19 +3,19 @@ using Vega @testset "show" begin -vg = Vega.VGSpec(Dict{String,Any}()) + vg = Vega.VGSpec(Dict{String,Any}()) -@test sprint(show, vg) == "Vega.VGSpec" + @test sprint(show, vg) == "Vega.VGSpec" -@test sprint(show, "text/plain", vg) == "@vgplot(\n\n)" + @test sprint(show, "text/plain", vg) == "@vgplot(\n\n)" -@test istextmime("application/vnd.vega.v5+json") + @test istextmime("application/vnd.vega.v5+json") -@test sprint(show, "application/vnd.vega.v5+json", vg"{}") == "{}" + @test sprint(show, "application/vnd.vega.v5+json", vg"{}") == "{}" -@test !showable(MIME("text/html"), vg) + @test !showable(MIME("text/html"), vg) -@test occursin("var spec = {}", sprint(show, "text/html", vg)) + @test occursin("var spec = {}", sprint(show, "text/html", vg)) end diff --git a/test/test_vg.jl b/test/test_vg.jl index b0c485a..89d4b39 100644 --- a/test/test_vg.jl +++ b/test/test_vg.jl @@ -9,48 +9,48 @@ include("testhelper_create_vg_plot.jl") @testset "VGSpec" begin -@test vg"""{ "data": [ { "name": "test" } ] }"""(URI("http://www.foo.com/bar.json"), "test") == vg""" - { - "data": [{ - "name": "test", - "url": "http://www.foo.com/bar.json" - }] - } - """ - -if Sys.iswindows() - @test vg"""{ "data": [ { "name": "test" } ] }"""(Path("/julia/dev"), "test") == vg""" + @test vg"""{ "data": [ { "name": "test" } ] }"""(URI("http://www.foo.com/bar.json"), "test") == vg""" { "data": [{ "name": "test", - "url": "file://julia/dev" + "url": "http://www.foo.com/bar.json" }] } """ -else - @test vg"""{ "data": [ { "name": "test" } ] }"""(Path("/julia/dev"), "test") == vg""" - { - "data": [{ - "name": "test", - "url": "file:///julia/dev" - }] - } - """ -end -df = DataFrame(a=[1.,2.], b=["A", "B"], c=[Date(2000), Date(2001)]) + if Sys.iswindows() + @test vg"""{ "data": [ { "name": "test" } ] }"""(Path("/julia/dev"), "test") == vg""" + { + "data": [{ + "name": "test", + "url": "file://julia/dev" + }] + } + """ + else + @test vg"""{ "data": [ { "name": "test" } ] }"""(Path("/julia/dev"), "test") == vg""" + { + "data": [{ + "name": "test", + "url": "file:///julia/dev" + }] + } + """ + end + + df = DataFrame(a=[1.0, 2.0], b=["A", "B"], c=[Date(2000), Date(2001)]) -p1 = getvgplot() + p1 = getvgplot() -p2 = deletedata(p1) -@test !haskey(getparams(p2)["data"][1], "values") + p2 = deletedata(p1) + @test !haskey(getparams(p2)["data"][1], "values") -p3 = p2(df, "table") + p3 = p2(df, "table") -@test getparams(p3)["data"][1]["values"][1]["b"] == "A" + @test getparams(p3)["data"][1]["values"][1]["b"] == "A" -deletedata!(p1) + deletedata!(p1) -@test p1 == p2 + @test p1 == p2 end