Custom legend vega-lite

433 views
Skip to first unread message

Mohit Chawla

unread,
Mar 1, 2020, 8:33:05 AM3/1/20
to vega-js
Hi all, 

Is it possible to specify an entirely custom legend in vega-lite?

I am either making a mistake or running into a bug where the legend for color and shape encodings are not being represented accurately. In the following code, I am using a different shape for one of the values ("C") for a field ("myField"). However, in the legend, this is not reflected, and all values ("A", "B" and "C") are shown with "triangle-down" as the symbol. Any suggestions?

    "color": {"field": "myField", "legend" : {"symbolType": "triangle-down"},"type": "nominal",  "scale": {"domain": ["A", "B", "C"], "range": ["aqua", "navy", "red"]}},

    "shape": {
      "condition": {
        "test": "datum.myField === 'C'",
        "value": "circle"
      }
     }

Thanks, 
Mohit

Mohit Chawla

unread,
Mar 1, 2020, 8:54:20 AM3/1/20
to vega-js
And just a note - I had to add the legend symbolType: "triangle-down" in the first place, because otherwise the legend only shows circles, even if the default mark shape is set to "triangle-down". 
Reply all
Reply to author
Forward
0 new messages