Search code examples
vega-lite

Vega lite: How to change value labels


I could not found out way how to change labels of X axis. I have this data and I need to show bars which have title taken from field label. Currently bars are aggregated by id and goals is to label bars with label even if the texts are same. I'm confused by examples what to do. Whether I should create layer or some signals. Could someone help me? IMHO this should be trivial, but I did not found anything useful.

      {
        "id": 15971,
        "label": "Click Next to continue",
        "result": "Success",
        "value": 2
      },
      {
        "id": 15972,
        "label": "Click Next to continue",
        "result": "No data",
        "value": 0
      },

Current Graph

Vega editor


Solution

  • There's not really any way to do this in the Vega-Lite grammar, because what you want to do is semantically inconsistent: if you group values by one column, there is no guarantee that the values in another column will match within that grouping.

    One option you have is to use labelExpr to define the desired label manually, e.g.

        "x": {
          "field": "id",
          "type": "nominal",
          "axis": {"title": "x", "labelExpr": "'Click Next to continue'"},
          "scale": {"type": "point"}
        },