vega-lite
vega-lite copied to clipboard
Clarify the differences between `value` and `datum` in the docs
I think the documentation could do a better job in highlighting the differences between value
and datum
, including when one is preferred over the other. I suggest the following:
- Rename the h1 on the datum page to
Data Value
orDatum
instead of justValue
(I thought I clicked the wrong link initially). - Explain what "visual value" is referring to on the encoding page for
value
since this is the only mention in the docs. Does it just mean "pixels"? - On the value doc page, add a use case of
value
outside initializing parameters and update the page h1 toValue
. Or clarify thatvalue
is only for initializing parameters on the encoding page. - Add a sentence to the encoding page that directly contrasts
datum
withvalue
. For example:"... while both
value
anddatum
can be used to specify single values in encoding channels, they differ in thatvalue
will encode the provided value in pixel units whereasdatum
will encode the provided value in scale/domain/data units.datum
also allows the specification of many of the same properties asfield
, such as ..."- (I am not sure if this is the main difference and how datum works when there is no scale/domain, is the type of the value inferred and a scale/domain created automatically?)
- Add an example contrasting using both for the same task. I like the two mentioned here.
I don't currently understand this well enough to submit a PR, but can do so if I get help clarifying points 2-5 above.
On part 2, value doesn't just mean pixels. It means range value (as opposed to domain value): for positional encodings, it is pixels from the top left. For color encodings, it is the actual RGB color. For shape encodings, it is the name of the shape. For size encodings, it is the area of the mark in square pixels (I think... or maybe it's diameter?) etc.
In addition, clicking the "Edit the page" link on the documentation always gives a 404. Link should be removed or repointed.
That's because we moved the master branch to next. We already fixed it but need to redeploy the docs when we make the next release.
Just coming here to note that I also struggled with this difference (and had asked about it on the Vega-Lite Slack). So great that the docs will be improved here.