Julia Environments / Aug 20 2019
VegaLite Environment
Update old Julia Image, and remove OpenGL plotting libraries to make image lighter!
]up; dev VegaLite; add VegaDatasets
VegaLite has problems building due npm running into file permissions, so we need to do it manually:
apt-get update apt-get install npm cd /root/.julia/dev/VegaLite/deps npm install --scripts-prepend-node-path=true --production --no-package-lock --no-optional
Now, one can use VegaLite,
using VegaLite, VegaDatasets vega_plot = dataset("cars") |> ( :point, x = :Horsepower, y = :Miles_per_Gallon, color = :Origin, width = 650, height = 400 ) |> VegaLite.interactive()
One can also write out a json file to /results/
, and it will display correctly if it contains valid Vega json and ends with the extension vl.json
:
open("/results/test.vl.json", "w") do io show(io, MIME"application/vnd.vegalite.v3+json"(), vega_plot) end
Loading viewer…
Or one can write out NamedTuples as JSON the same way:
data = ( width = 650, height = 400, data = ( url = "https://vega.github.io/vega-datasets/data/us-10m.json", format = (type = "topojson", feature = "counties") ), transform = [( lookup = "id", from = ( data = ( url = "https://vega.github.io/vega-datasets/data/unemployment.tsv", ), key = "id", fields = ["rate"] ) )], projection = (type = "albersUsa",), mark = "geoshape", encoding = (color = (field = "rate", type = "quantitative"),) ) using JSON open("/results/test.vl.json", "w") do io JSON.print(io, data) end
Loading viewer…