From 9d05ab93ade5ff9cd8a53c0b8b71b1091449dec1 Mon Sep 17 00:00:00 2001 From: davidanthoff Date: Sat, 10 Feb 2024 20:45:41 +0000 Subject: [PATCH] Format files using DocumentFormat --- docs/make.jl | 74 ++--- src/VegaLite.jl | 2 +- .../dsl_vlplot_function.jl | 14 +- src/dsl_vlplot_function/shorthandparser.jl | 10 +- src/dsl_vlplot_macro/dsl_vlplot_macro.jl | 2 +- src/rendering/fileio.jl | 2 +- src/rendering/io.jl | 4 +- src/rendering/render.jl | 265 +++++++++--------- src/rendering/show.jl | 10 +- src/vlspec.jl | 20 +- test/test_base.jl | 8 +- test/test_inlinedata.jl | 8 +- test/test_io.jl | 11 +- test/test_macro.jl | 28 +- test/test_positional.jl | 10 +- test/test_show.jl | 4 +- test/test_spec.jl | 12 +- test/test_vg.jl | 2 +- test/test_vlplot_macro.jl | 22 +- 19 files changed, 259 insertions(+), 249 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 9d1d3c78..fef84fe0 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -3,52 +3,52 @@ using Documenter, VegaLite, UUIDs function Base.show(io::IO, m::MIME"text/html", v::VegaLite.VLSpec) divid = string("vl", replace(string(uuid4()), "-" => "")) print(io, "
") - print(io, "") end makedocs( - modules=[VegaLite], - sitename="VegaLite.jl", - pages=[ - "Home" => "index.md", - "Getting Started" => Any[ - "Installation" => "gettingstarted/installation.md", - "Tutorial" => "gettingstarted/tutorial.md" - ], - "User Guide" => Any[ - "Vega-lite specifications" => "userguide/vlspec.md", - "The @vlplot command" => "userguide/vlplotmacro.md", - "Data sources" => "userguide/data.md" - ], - "Examples" => Any[ - "Single-View Plots" => Any[ - "Bar Charts" => "examples/examples_barcharts.md", - "Histograms, Density Plots, and Dot Plots" => "examples/examples_histograms.md", - "Scatter & Strip Plots" => "examples/examples_scatter_strip_plots.md", - "Line Charts" => "examples/examples_line_charts.md", - "Area Charts & Streamgraphs" => "examples/examples_area_Charts_streamgraphs.md", - "Table-based Plots" => "examples/examples_table_based_plots.md", - "Circular Plots" => "examples/examples_circular_plots.md", - "Advanced Calculations" => "examples/examples_advancedcalculations.md" + modules=[VegaLite], + sitename="VegaLite.jl", + pages=[ + "Home" => "index.md", + "Getting Started" => Any[ + "Installation"=>"gettingstarted/installation.md", + "Tutorial"=>"gettingstarted/tutorial.md" ], - "Composite Mark" => Any[ - "Error Bars & Error Bands" => "examples/examples_error_bars_bands.md", - "Box Plots" => "examples/examples_box_plots.md" + "User Guide" => Any[ + "Vega-lite specifications"=>"userguide/vlspec.md", + "The @vlplot command"=>"userguide/vlplotmacro.md", + "Data sources"=>"userguide/data.md" ], - "Multi-View Displays" => Any[ - "Faceting (Trellis Plot / Small Multiples)" => "examples/examples_faceting.md", - "Repeat & Concatenation" => "examples/examples_repeat_concatenation.md" + "Examples" => Any[ + "Single-View Plots"=>Any[ + "Bar Charts"=>"examples/examples_barcharts.md", + "Histograms, Density Plots, and Dot Plots"=>"examples/examples_histograms.md", + "Scatter & Strip Plots"=>"examples/examples_scatter_strip_plots.md", + "Line Charts"=>"examples/examples_line_charts.md", + "Area Charts & Streamgraphs"=>"examples/examples_area_Charts_streamgraphs.md", + "Table-based Plots"=>"examples/examples_table_based_plots.md", + "Circular Plots"=>"examples/examples_circular_plots.md", + "Advanced Calculations"=>"examples/examples_advancedcalculations.md" + ], + "Composite Mark"=>Any[ + "Error Bars & Error Bands"=>"examples/examples_error_bars_bands.md", + "Box Plots"=>"examples/examples_box_plots.md" + ], + "Multi-View Displays"=>Any[ + "Faceting (Trellis Plot / Small Multiples)"=>"examples/examples_faceting.md", + "Repeat & Concatenation"=>"examples/examples_repeat_concatenation.md" + ], + "Maps (Geographic Displays)"=>"examples/examples_maps.md" ], - "Maps (Geographic Displays)" => "examples/examples_maps.md" - ], - "Reference Manual" => [ - "Global settings" => "referencemanual/global.md", - "Outputs" => "referencemanual/output.md", - "Performance tips" => "referencemanual/performance.md", + "Reference Manual" => [ + "Global settings" => "referencemanual/global.md", + "Outputs" => "referencemanual/output.md", + "Performance tips" => "referencemanual/performance.md", ] - ] + ] ) deploydocs( diff --git a/src/VegaLite.jl b/src/VegaLite.jl index 1e572b08..76052bbe 100644 --- a/src/VegaLite.jl +++ b/src/VegaLite.jl @@ -32,7 +32,7 @@ export deletedata, deletedata! vegalite_app_path(args...) = joinpath(artifact"vegalite_app", args...) const vegaliate_app_includes_canvas = Ref{Bool}() -const vlschema = Ref{Dict{String, Any}}() +const vlschema = Ref{Dict{String,Any}}() function __init__() vegaliate_app_includes_canvas[] = ispath(vegalite_app_path("node_modules", "canvas")) diff --git a/src/dsl_vlplot_function/dsl_vlplot_function.jl b/src/dsl_vlplot_function/dsl_vlplot_function.jl index 71758d89..29d592cf 100644 --- a/src/dsl_vlplot_function/dsl_vlplot_function.jl +++ b/src/dsl_vlplot_function/dsl_vlplot_function.jl @@ -96,7 +96,7 @@ function fix_shortcut_level_data(spec_frag) if TableTraits.isiterabletable(spec_frag) it = IteratorInterfaceExtensions.getiterator(spec_frag) return VLFrag([], OrderedDict{String,Any}("values" => Vega.DataValuesNode(it))) -else + else return spec_frag end end @@ -105,7 +105,7 @@ function fix_shortcut_level_spec(spec_frag::VLFrag) spec = copy(spec_frag.named) if length(spec_frag.positional) > 0 - spec["mark"] = spec_frag.positional[1] + spec["mark"] = spec_frag.positional[1] elseif length(spec_frag.positional) > 3 error("More than three positional element specified at the spec level.") end @@ -119,7 +119,7 @@ function fix_shortcut_level_spec(spec_frag::VLFrag) encodings_to_be_moved = filter( i -> i != "facet", collect(keys(vlschema[]["definitions"]["FacetedEncoding"]["properties"])), - ) + ) for k in collect(keys(spec)) if string(k) in encodings_to_be_moved if !haskey(spec, "encoding") @@ -163,7 +163,7 @@ function fix_shortcut_level_spec(spec_frag::VLFrag) inline_unnamed_data = Pair{Symbol,AbstractVector}[] if haskey(spec, "encoding") - if spec["encoding"] isa VLFrag + if spec["encoding"] isa VLFrag if !isempty(spec["encoding"].positional) error("Can't have positional arguments inside the encoding element.") else @@ -226,12 +226,12 @@ function convert_frag_tree_to_dict(spec::VLFrag) return "type" => p[2] else return p -end + end end return spec_as_dict2 end -function vlplot(args...;kwargs...) - return VLSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec(vlfrag(args...;kwargs...)))) +function vlplot(args...; kwargs...) + return VLSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec(vlfrag(args...; kwargs...)))) end diff --git a/src/dsl_vlplot_function/shorthandparser.jl b/src/dsl_vlplot_function/shorthandparser.jl index e3ad4ed4..96e6060a 100644 --- a/src/dsl_vlplot_function/shorthandparser.jl +++ b/src/dsl_vlplot_function/shorthandparser.jl @@ -69,18 +69,18 @@ function parse_shortcut(s::AbstractString) if length(tokens) > 2 && tokens[3] == ")" if length(tokens) == 3 decoded_func = decode_func(tokens[1]) - return [decoded_func,"type" => decoded_func[1] == "timeUnit" ? "temporal" : "quantitative"] + return [decoded_func, "type" => decoded_func[1] == "timeUnit" ? "temporal" : "quantitative"] elseif length(tokens) == 5 && tokens[4] == ":" - return [decode_func(tokens[1]),decode_typ(tokens[5])] + return [decode_func(tokens[1]), decode_typ(tokens[5])] else throw(ArgumentError("invalid shortcut string")) end elseif length(tokens) > 3 && tokens[4] == ")" if length(tokens) == 4 decoded_func = decode_func(tokens[1]) - return [decoded_func,"field" => tokens[3],"type" => decoded_func[1] == "timeUnit" ? "temporal" : "quantitative"] + return [decoded_func, "field" => tokens[3], "type" => decoded_func[1] == "timeUnit" ? "temporal" : "quantitative"] elseif length(tokens) == 6 && tokens[5] == ":" - return [decode_func(tokens[1]),"field" => tokens[3],decode_typ(tokens[6])] + return [decode_func(tokens[1]), "field" => tokens[3], decode_typ(tokens[6])] else throw(ArgumentError("invalid shortcut string")) end @@ -88,7 +88,7 @@ function parse_shortcut(s::AbstractString) throw(ArgumentError("Invalid shortcut string")) end elseif length(tokens) == 3 && tokens[2] == ":" - return ["field" => tokens[1],decode_typ(tokens[3])] + return ["field" => tokens[1], decode_typ(tokens[3])] else throw(ArgumentError("Invalid shortcut string")) end diff --git a/src/dsl_vlplot_macro/dsl_vlplot_macro.jl b/src/dsl_vlplot_macro/dsl_vlplot_macro.jl index c49880e7..e28791de 100644 --- a/src/dsl_vlplot_macro/dsl_vlplot_macro.jl +++ b/src/dsl_vlplot_macro/dsl_vlplot_macro.jl @@ -1,7 +1,7 @@ macro vlplot(ex...) new_ex = Vega.convert_curly_style(ex, VLFrag) - return :( VegaLite.VLSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec($new_ex))) ) + return :(VegaLite.VLSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec($new_ex)))) end macro vlfrag(ex...) diff --git a/src/rendering/fileio.jl b/src/rendering/fileio.jl index 62251391..806d9fcf 100644 --- a/src/rendering/fileio.jl +++ b/src/rendering/fileio.jl @@ -26,4 +26,4 @@ function fileio_save(stream::FileIO.Stream{FileIO.format"vega"}, data::VLSpec; i parsed = JSON.parse(s) vgspec = Vega.VGSpec(parsed) Vega.savespec(stream.io, vgspec; include_data=include_data, kwargs...) -end \ No newline at end of file +end diff --git a/src/rendering/io.jl b/src/rendering/io.jl index fe30edec..b961bcde 100644 --- a/src/rendering/io.jl +++ b/src/rendering/io.jl @@ -20,8 +20,8 @@ function savefig(filename::AbstractString, v::VLSpec) mime = "image/png" elseif file_ext == ".eps" mime = "application/eps" - # elseif file_ext == ".ps" - # mime = "application/postscript" + # elseif file_ext == ".ps" + # mime = "application/postscript" else throw(ArgumentError("Unknown file type.")) end diff --git a/src/rendering/render.jl b/src/rendering/render.jl index d7fec5de..ebdafa31 100644 --- a/src/rendering/render.jl +++ b/src/rendering/render.jl @@ -7,14 +7,14 @@ using JSON asset(url...) = normpath(vegalite_app_path("minified", url...)) -const package_json = Ref{Dict{String, Any}}() +const package_json = Ref{Dict{String,Any}}() function version(package) - if !isassigned(package_json) - package_json[] = JSON.parsefile(vegalite_app_path("package.json")) - end - - return package_json[]["dependencies"][package] + if !isassigned(package_json) + package_json[] = JSON.parsefile(vegalite_app_path("package.json")) + end + + return package_json[]["dependencies"][package] end # Vega Scaffold: https://github.com/vega/vega/wiki/Runtime @@ -27,48 +27,51 @@ function writehtml_full(io::IO, spec::VLSpec; title="VegaLite plot") divid = "vg" * randstring(3) print(io, - """ - - - $title - - - - - - -
- - - - - + + + + +
+ + + + + + - - """) + +""" + ) end function writehtml_full(spec::VLSpec; title="VegaLite plot") @@ -88,63 +91,63 @@ VegaLite js files are loaded from the web (to accommodate the security model of IJulia) using requirejs. """ function writehtml_partial_require(io::IO, spec::String; title="VegaLite plot") - divid = "vg" * randstring(3) + divid = "vg" * randstring(3) println(io, - """ - - -
- - - - - - - - """) + """ + + +
+ + + + + + + + """) end """ @@ -152,40 +155,46 @@ 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::VLSpec; title="VegaLite plot") - divid = "vg" * randstring(3) - print(io, """ - - - - - - -
- - - """) + divid = "vg" * randstring(3) + print( + io, + """ + + + + + + +
+ + +""" + ) end function Base.display(d::REPL.REPLDisplay, plt::VLSpec) - # checkplot(plt) + # checkplot(plt) tmppath = writehtml_full(plt) Vega.launch_browser(tmppath) # Open the browser end diff --git a/src/rendering/show.jl b/src/rendering/show.jl index 71e74ca5..6e4676d8 100644 --- a/src/rendering/show.jl +++ b/src/rendering/show.jl @@ -1,7 +1,7 @@ function convert_vl_to_x(v::VLSpec, fileformat; cmd_args="") script_path = vegalite_app_path("node_modules", "vega-lite", "bin", "vl2$fileformat") - p = open(Cmd(`$(NodeJS.nodejs_cmd()) $script_path $cmd_args`, dir=vegalite_app_path()),"r+") + p = open(Cmd(`$(NodeJS.nodejs_cmd()) $script_path $cmd_args`, dir=vegalite_app_path()), "r+") buffered_output_stream = BufferedStreams.BufferedOutputStream(p.in) @@ -13,10 +13,10 @@ function convert_vl_to_x(v::VLSpec, fileformat; cmd_args="") reader = @async read(p, String) - wait(writer) - wait(p) + wait(writer) + wait(p) res = fetch(reader) - + if p.exitcode != 0 throw(ArgumentError("Invalid spec")) end @@ -76,7 +76,7 @@ function Base.show(io::IO, m::MIME"image/png", v::VLSpec) if vegaliate_app_includes_canvas[] if haskey(io, :ppi) print(io, convert_vl_to_x(v, "png", cmd_args="--ppi=$(io[:ppi])")) - else + else print(io, convert_vl_to_x(v, "png")) end else diff --git a/src/vlspec.jl b/src/vlspec.jl index f9a9b259..9d0463e9 100644 --- a/src/vlspec.jl +++ b/src/vlspec.jl @@ -39,7 +39,7 @@ function augment_encoding_type(x::AbstractDict, data::Vega.DataValuesNode) end function augment_encoding_type(x::AbstractArray, data::Vega.DataValuesNode) - x = [augment_encoding_type(k,data) for k in x] + x = [augment_encoding_type(k, data) for k in x] return x end @@ -49,8 +49,8 @@ function add_encoding_types(specdict, parentdata=nothing) newspec = OrderedDict{String,Any}( (k == "encoding" && v isa AbstractDict) ? k => OrderedDict{String,Any}(kk => augment_encoding_type(vv, data) for (kk, vv) in v) : - k == "spec" ? k => add_encoding_types(v, data) : - k in ("layer", "concat", "vconcat", "hconcat") ? k => [add_encoding_types(i, data) for i in v] : k => v for (k, v) in specdict + k == "spec" ? k => add_encoding_types(v, data) : + k in ("layer", "concat", "vconcat", "hconcat") ? k => [add_encoding_types(i, data) for i in v] : k => v for (k, v) in specdict ) return newspec @@ -75,7 +75,7 @@ function (p::VLSpec)(data) new_dict["data"] = OrderedDict{String,Any}("values" => datavaluesnode) return VLSpec(new_dict) - end +end function (p::VLSpec)(uri::URI) new_dict = copy(Vega.getparams(p)) @@ -143,10 +143,10 @@ function Base.hcat(A::VLSpec...) end function Base.vcat(A::VLSpec...) - spec = VLSpec(OrderedDict{String,Any}()) - Vega.getparams(spec)["vconcat"] = [] - for i in A - push!(Vega.getparams(spec)["vconcat"], deepcopy(Vega.getparams(i))) - end - return spec + spec = VLSpec(OrderedDict{String,Any}()) + Vega.getparams(spec)["vconcat"] = [] + for i in A + push!(Vega.getparams(spec)["vconcat"], deepcopy(Vega.getparams(i))) + end + return spec end diff --git a/test/test_base.jl b/test/test_base.jl index 42dad8e4..454b8aa8 100644 --- a/test/test_base.jl +++ b/test/test_base.jl @@ -1,8 +1,8 @@ @testitem "base" begin - using VegaLite:Vega.getparams + using VegaLite: Vega.getparams equiv(a::VegaLite.VLSpec, b::VegaLite.VLSpec) = - ==(Vega.getparams(a), Vega.getparams(b)) + ==(Vega.getparams(a), Vega.getparams(b)) ### @test isa(renderer(), Symbol) @@ -17,6 +17,6 @@ @test actionlinks() == false ts = collect(range(0, stop=2, length=100)) - rs = Float64[ rand() * 0.1 + cos(x) for x in ts] - datvals = [ Dict(:time => t, :res => r) for (t, r) in zip(ts, rs) ] + rs = Float64[rand() * 0.1 + cos(x) for x in ts] + datvals = [Dict(:time => t, :res => r) for (t, r) in zip(ts, rs)] end diff --git a/test/test_inlinedata.jl b/test/test_inlinedata.jl index 6f10e7b6..2c4a7793 100644 --- a/test/test_inlinedata.jl +++ b/test/test_inlinedata.jl @@ -1,10 +1,10 @@ @testitem "Inline Data" begin using DataFrames - @test @vlplot(:point, x = {[1,2,3]}, y = [4,5,6]) == - @vlplot(:point, data = DataFrame(x=[1,2,3], y=[4,5,6]), x = {:x, title = nothing}, y = {:y, title = nothing}) + @test @vlplot(:point, x = {[1, 2, 3]}, y = [4, 5, 6]) == + @vlplot(:point, data = DataFrame(x=[1, 2, 3], y=[4, 5, 6]), x = {:x, title = nothing}, y = {:y, title = nothing}) - @test @vlplot(:point, x = {[1,2,3], title = :test}, y = [4,5,6]) == - @vlplot(:point, data = DataFrame(x=[1,2,3], y=[4,5,6]), x = {:x, title = :test}, y = {:y, title = nothing}) + @test @vlplot(:point, x = {[1, 2, 3], title = :test}, y = [4, 5, 6]) == + @vlplot(:point, data = DataFrame(x=[1, 2, 3], y=[4, 5, 6]), x = {:x, title = :test}, y = {:y, title = nothing}) end diff --git a/test/test_io.jl b/test/test_io.jl index d1e725b0..2708f806 100644 --- a/test/test_io.jl +++ b/test/test_io.jl @@ -6,18 +6,19 @@ using FileIO include("testhelper_create_vg_plot.jl") - - p = DataFrame(x=[1,2,3], y=[1,2,3]) |> @vlplot(:point, x = "x:q", y = "y:q") + + p = DataFrame(x=[1, 2, 3], y=[1, 2, 3]) |> @vlplot(:point, x = "x:q", y = "y:q") vgp = getvgplot() vlp = getvlplot() @testset "$fmt (indent=$(repr(indent)))" for (fmt, plt) in [ - (format"vegalite", vlp) - ], + (format"vegalite", vlp) + ], indent in [nothing, 4] let json = sprint(io -> save(Stream{fmt}(io), plt, indent=indent)), code = "vg\"\"\"$json\"\"\"" + @test Vega.getparams(include_string(@__MODULE__, code)) == Vega.getparams(plt) end @@ -31,7 +32,7 @@ @test Vega.getparams(include_string(@__MODULE__, code)) == Vega.getparams(plt) end end - + Base.Filesystem.mktempdir() do folder VegaLite.svg(joinpath(folder, "test1.svg"), p) @test isfile(joinpath(folder, "test1.svg")) diff --git a/test/test_macro.jl b/test/test_macro.jl index 206334d3..72aff2f9 100644 --- a/test/test_macro.jl +++ b/test/test_macro.jl @@ -2,21 +2,21 @@ using VegaLite: Vega.getparams using Vega using JSON - - spec = vl""" - { - "data": { - "values": [ - {"a": "A","b": 28}, {"a": "B","b": 55} - ] - }, - "mark": "bar", - "encoding": { - "x": {"field": "a", "type": "ordinal"}, - "y": {"field": "b", "type": "quantitative"} - } + + spec = vl""" + { + "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, VegaLite.VLSpec) @test Vega.getparams(spec) == JSON.parse(""" diff --git a/test/test_positional.jl b/test/test_positional.jl index a1a6aebe..b00d1b2b 100644 --- a/test/test_positional.jl +++ b/test/test_positional.jl @@ -1,12 +1,12 @@ @testitem "Positional shortcuts" begin using DataFrames - df = DataFrame(a=[1,2,3], b=[4,5,6]) + df = DataFrame(a=[1, 2, 3], b=[4, 5, 6]) - @test @vlplot(:point, [1,2,3]) == @vlplot(:point, x = [1,2,3]) - @test @vlplot(:point, {[1,2,3]}) == @vlplot(:point, x = [1,2,3]) - @test @vlplot(:point, [1,2,3], [4,5,6]) == @vlplot(:point, x = [1,2,3], y = [4,5,6]) - @test @vlplot(:point, {[1,2,3]}, {[4,5,6]}) == @vlplot(:point, x = [1,2,3], y = [4,5,6]) + @test @vlplot(:point, [1, 2, 3]) == @vlplot(:point, x = [1, 2, 3]) + @test @vlplot(:point, {[1, 2, 3]}) == @vlplot(:point, x = [1, 2, 3]) + @test @vlplot(:point, [1, 2, 3], [4, 5, 6]) == @vlplot(:point, x = [1, 2, 3], y = [4, 5, 6]) + @test @vlplot(:point, {[1, 2, 3]}, {[4, 5, 6]}) == @vlplot(:point, x = [1, 2, 3], y = [4, 5, 6]) @test @vlplot(:point, :a, data = df) == @vlplot(:point, x = :a, data = df) @test @vlplot(:point, :a, :b, data = df) == @vlplot(:point, x = :a, y = :b, data = df) @test @vlplot(:point, {:a}, data = df) == @vlplot(:point, x = :a, data = df) diff --git a/test/test_show.jl b/test/test_show.jl index a63985b5..698d94b0 100644 --- a/test/test_show.jl +++ b/test/test_show.jl @@ -1,6 +1,6 @@ @testitem "show" begin using Vega - + vl = @vlplot(:point) vg = Vega.VGSpec(Dict{String,Any}()) @@ -24,6 +24,6 @@ @test !showable(MIME("text/html"), vl) - @test occursin("var spec = {\"mark\":\"point\"}", sprint(show, "text/html",vl)) + @test occursin("var spec = {\"mark\":\"point\"}", sprint(show, "text/html", vl)) end diff --git a/test/test_spec.jl b/test/test_spec.jl index 135835ee..832a7f48 100644 --- a/test/test_spec.jl +++ b/test/test_spec.jl @@ -16,7 +16,7 @@ @test_throws ArgumentError @vlplot()(5) - df = DataFrame(a=[1.,2.], b=["A", "B"], c=[Date(2000), Date(2001)]) + df = DataFrame(a=[1., 2.], b=["A", "B"], c=[Date(2000), Date(2001)]) p1 = (df |> @vlplot("line", x = :c, y = :a, color = :b)) p2 = vl""" @@ -44,7 +44,7 @@ @test p1 == p2 - p3 = DataFrame(a=[1,2,missing], b=[3.,2.,1.]) |> @vlplot(:point, x = :a, y = :b) + p3 = DataFrame(a=[1, 2, missing], b=[3., 2., 1.]) |> @vlplot(:point, x = :a, y = :b) p4 = vl""" { @@ -86,8 +86,8 @@ end @testitem "Array tooltip data" begin - using VegaDatasets - - p10 = dataset("cars")|> @vlplot(:point,x=:Horsepower,y=:Miles_per_Gallon,tooltip=[:Horsepower,"Miles_per_Gallon:q"]) - @test isa(p10.encoding.tooltip, Vector) + using VegaDatasets + + p10 = dataset("cars") |> @vlplot(:point, x = :Horsepower, y = :Miles_per_Gallon, tooltip = [:Horsepower, "Miles_per_Gallon:q"]) + @test isa(p10.encoding.tooltip, Vector) end diff --git a/test/test_vg.jl b/test/test_vg.jl index 14c2888f..dbb5df0b 100644 --- a/test/test_vg.jl +++ b/test/test_vg.jl @@ -37,7 +37,7 @@ """ end - df = DataFrame(a=[1.,2.], b=["A", "B"], c=[Date(2000), Date(2001)]) + df = DataFrame(a=[1., 2.], b=["A", "B"], c=[Date(2000), Date(2001)]) p1 = getvgplot() diff --git a/test/test_vlplot_macro.jl b/test/test_vlplot_macro.jl index 44f00cad..1d552fc0 100644 --- a/test/test_vlplot_macro.jl +++ b/test/test_vlplot_macro.jl @@ -72,26 +72,26 @@ } """) - @test (@vlplot(description = "foo") + @vlplot(:point) + @vlplot(:circle)) == @vlplot(description = "foo", layer = [{mark = :point},{mark = :circle}]) + @test (@vlplot(description = "foo") + @vlplot(:point) + @vlplot(:circle)) == @vlplot(description = "foo", layer = [{mark = :point}, {mark = :circle}]) @test (@vlplot(facet = {row = {field = :foo, type = :bar}}) + @vlplot(:point)) == @vlplot(facet = {row = {field = :foo, type = :bar}}, spec = {mark = :point}) @test (@vlplot(repeat = {column = [:foo, :bar]}) + @vlplot(:point)) == @vlplot(repeat = {column = [:foo, :bar]}, spec = {mark = :point}) - @test (@vlplot(description = "foo") + [@vlplot(:point) @vlplot(:circle)]) == @vlplot(description = "foo", hconcat = [{mark = :point},{mark = :circle}]) + @test (@vlplot(description = "foo") + [@vlplot(:point) @vlplot(:circle)]) == @vlplot(description = "foo", hconcat = [{mark = :point}, {mark = :circle}]) - @test (@vlplot(description = "foo") + [@vlplot(:point); @vlplot(:circle)]) == @vlplot(description = "foo", vconcat = [{mark = :point},{mark = :circle}]) + @test (@vlplot(description = "foo") + [@vlplot(:point); @vlplot(:circle)]) == @vlplot(description = "foo", vconcat = [{mark = :point}, {mark = :circle}]) @test (@vlplot(:point, x = :a)(DataFrame(a=[1])) == @vlplot(:point, data = DataFrame(a=[1]), x = :a)) - @test @vlplot("point", wrap = :x) == vl""" - { - "mark": "point", - "encoding": { - "facet": {"field": "x"} - } - } - """ + @test @vlplot("point", wrap = :x) == vl""" + { + "mark": "point", + "encoding": { + "facet": {"field": "x"} + } + } + """ @test @vlplot("point", enc = {x = :foo}, wrap = :x) == vl""" {