vega / vega-lite

A concise grammar of interactive graphics, built on Vega.
https://vega.github.io/vega-lite/
BSD 3-Clause "New" or "Revised" License
4.68k stars 611 forks source link

support list/array for datum for text encoding #9166

Open mattijn opened 1 year ago

mattijn commented 1 year ago

It would be great if "datum" within the text-encoding channel accepts a list/array as input as such ["text", "over", "multi-lines"].

If I try this within the editor then the chart renders successfully:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {"values": [{}]},
  "mark": {"type": "text", "size": 14},
  "encoding": {
    "text": {"datum": ["text", "over", "multi-lines"]},
    "x": {"datum": 0, "scale": {"domain": [-1, 1]}},
    "y": {"datum": 0, "scale": {"domain": [-1, 1]}}
  }
}
image

Open the Chart in the Vega Editor

But the vega-lite grammar does currently not allow it:

image

With an validation warning stating:

[Warning] Validation: /encoding/text/datum must be number,string,boolean,null of #/definitions/PrimitiveValue/type
[Warning] Validation: /encoding/text/datum must be object of #/type
[Warning] Validation: /encoding/text/datum must be object of #/definitions/ExprRef/type
[Warning] Validation: /encoding/text/datum must be object of #/definitions/RepeatRef/type
[Warning] Validation: /encoding/text/datum must match a schema in anyOf of #/properties/datum/anyOf
kanitw commented 1 year ago

Some notes if someone wanna help fix this:

Relevant type definitions are