Main aim of PR is to add support for layered plots (so that we support error-bars, etc), but in doing so I needed to refactor some of the DSL to make it fit.
Here's an example of what Layers look like:
Vegas.layered("Plots both mean and IQR as a background layer").
withDataURL(Population).
withLayers(
Layer().
mark(Line).
encodeX("age", Ordinal).
encodeY("people", aggregate=Mean),
Layer().
mark(Area).
encodeX("age", Ordinal).
encodeY("people", aggregate=Q1).
encodeY2("people", aggregate=Q3)
)
Other changes include:
Started a new set of example plots called VegasPlots.scala for sticking in our own examples. They're included in look and unit tests
Refactored URLs of external data sources into constants file data.External
Making the DSL traits fit together has gotten more complicated but flexible. They now have a type parameter for the Builder they are being mixed into. This lets them be mixed-and-matched across different builders. Necessary since we now have a LayerSpecBuilder too.
The nested parameters for Scale and Axis are now handled quite differently. Instead of having these flattened in the DSL as axisX(...), scaleSize(...), etc. They now have their own case-classes. See AxisDSL.scala, and ScaleDSL.scala. I think this is a better layout for other DSL nested parameters, such as Config, Ledgend, etc too.
Regarding the last point, here's what the new DSL looks like:
val AggregateBarChart =
Vegas("A bar chart showing the US population distribution of age groups in 2000.").
withDataURL("https://vega.github.io/vega-editor/app/data/population.json").
mark(Bar).
transformFilter("datum.year == 2000").
encodeY("age", Ordinal, scale=Scale(bandSize=17)).
encodeX("people", Quantitative, aggregate=Sum, axis=Axis(title="population"))
Main aim of PR is to add support for layered plots (so that we support error-bars, etc), but in doing so I needed to refactor some of the DSL to make it fit.
Here's an example of what Layers look like:
Other changes include:
VegasPlots.scala
for sticking in our own examples. They're included inlook
and unit testsdata.External
LayerSpecBuilder
too.axisX(...)
,scaleSize(...)
, etc. They now have their own case-classes. SeeAxisDSL.scala
, andScaleDSL.scala
. I think this is a better layout for other DSL nested parameters, such as Config, Ledgend, etc too.Regarding the last point, here's what the new DSL looks like: