Production rules in legend

Hi
I would like to use production rules in vega legend - simplified example - I want a circle near number 10 to be orange.

I assume my code should looks like this

{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "padding": 5,
  "data": [{"name": "source", "url": "data/cars.json"}],
  "scales": [
    {
      "name": "size",
      "type": "linear",
      "round": true,
      "nice": false,
      "zero": true,
      "domain": {"data": "source", "field": "Acceleration"},
      "range": [4, 361]
    }
  ],
  "legends": [
    {
      "size": "size",
      "encode": {"symbols": {"update": 
      {"stroke": [{"test": "datum.key == 10", "value": "orange"}, {"value": "blue"}]}}},
      "symbolType": "circle"
    }
  ]
}

But I am struggeling with part {"test": "datum.key == 10", "value": "orange"}
How to test data in legend?

Thank you
Misa

Got it by myself :slight_smile:

{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "padding": 5,
  "data": [{"name": "source", "url": "data/cars.json"}],
  "scales": [
    {
      "name": "size",
      "type": "linear",
      "round": true,
      "nice": false,
      "zero": true,
      "domain": {"data": "source", "field": "Acceleration"},
      "range": [4, 361]
    }
  ],
  "legends": [
    {
      "size": "size",
      "encode": {"symbols": {"update": 
      {"stroke": [{"test": "datum.value == 10", "value": "orange"}, {"value": "blue"}]}}},
      "symbolType": "circle"
    }
  ]
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.