Skip to content

Commit

Permalink
Format files using DocumentFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
davidanthoff authored Oct 14, 2022
1 parent 28e7689 commit 943d47c
Show file tree
Hide file tree
Showing 22 changed files with 599 additions and 589 deletions.
74 changes: 37 additions & 37 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<div id='$divid' style=\"width:100%;height:100%;\"></div>")
print(io, "<script type='text/javascript'>requirejs.config({paths:{'vg-embed': 'https://cdn.jsdelivr.net/npm/vega-embed@6?noext','vega-lib': 'https://cdn.jsdelivr.net/npm/vega-lib?noext','vega-lite': 'https://cdn.jsdelivr.net/npm/vega-lite@4?noext','vega': 'https://cdn.jsdelivr.net/npm/vega@5?noext'}}); require(['vg-embed'],function(vegaEmbed){vegaEmbed('#$divid',")
print(io, "<script type='text/javascript'>requirejs.config({paths:{'vg-embed': 'https://cdn.jsdelivr.net/npm/vega-embed@6?noext','vega-lib': 'https://cdn.jsdelivr.net/npm/vega-lib?noext','vega-lite': 'https://cdn.jsdelivr.net/npm/vega-lite@4?noext','vega': 'https://cdn.jsdelivr.net/npm/vega@5?noext'}}); require(['vg-embed'],function(vegaEmbed){vegaEmbed('#$divid',")
VegaLite.our_json_print(io, v)
print(io, ",{mode:'vega-lite'}).catch(console.warn);})</script>")
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(
Expand Down
2 changes: 1 addition & 1 deletion src/VegaLite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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"))
Expand Down
14 changes: 7 additions & 7 deletions src/dsl_vlplot_function/dsl_vlplot_function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
10 changes: 5 additions & 5 deletions src/dsl_vlplot_function/shorthandparser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,26 @@ 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
else
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
Expand Down
2 changes: 1 addition & 1 deletion src/dsl_vlplot_macro/dsl_vlplot_macro.jl
Original file line number Diff line number Diff line change
@@ -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...)
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/fileio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
end
4 changes: 2 additions & 2 deletions src/rendering/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 943d47c

Please sign in to comment.