vega-lite icon indicating copy to clipboard operation
vega-lite copied to clipboard

Clarify the differences between `value` and `datum` in the docs

Open joelostblom opened this issue 2 years ago • 4 comments

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:

  1. Rename the h1 on the datum page to Data Value or Datum instead of just Value (I thought I clicked the wrong link initially).
  2. 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"?
  3. On the value doc page, add a use case of value outside initializing parameters and update the page h1 to Value. Or clarify that value is only for initializing parameters on the encoding page.
  4. Add a sentence to the encoding page that directly contrasts datum with value. For example:

    "... while both value and datum can be used to specify single values in encoding channels, they differ in that value will encode the provided value in pixel units whereas datum will encode the provided value in scale/domain/data units. datum also allows the specification of many of the same properties as field, 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?)
  5. 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.

joelostblom avatar Mar 24 '22 16:03 joelostblom

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.

jakevdp avatar Mar 24 '22 16:03 jakevdp

In addition, clicking the "Edit the page" link on the documentation always gives a 404. Link should be removed or repointed.

PBI-David avatar Mar 25 '22 09:03 PBI-David

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.

domoritz avatar Mar 25 '22 13:03 domoritz

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.

jonfroehlich avatar May 07 '22 00:05 jonfroehlich