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

Boolean field selection issue when selection is bound to legend

Open hannahburkhardt opened this issue 2 years ago • 0 comments

When binding a selection for a boolean field to the legend, I can select "true" as expected, but for "false", I have to click between the symbol and the word. Clicking on the symbol (circle in the example below) or the string "false" produces the following error in the log: [Error] Cannot read properties of undefined (reading '0')

Example:

{
  "config": {"view": {"continuousWidth": 400, "continuousHeight": 300}},
  "data": {
    "url": "https://cdn.jsdelivr.net/npm/[email protected]/data/barley.json"
  },
  "mark": "point",
  "encoding": {
    "color": {"field": "variety", "type": "nominal"},
    "opacity": {
      "condition": {"value": 1, "selection": "selector022"},
      "value": 0.2
    },
    "shape": {"field": "b", "type": "nominal"},
    "x": {"field": "year", "type": "ordinal"},
    "y": {"field": "yield", "type": "quantitative"}
  },
  "selection": {
    "selector022": {"type": "multi", "fields": ["b"], "bind": "legend"}
  },
  "transform": [{"calculate": "datum.variety=='Glabron'", "as": "b"}],
  "$schema": "https://vega.github.io/schema/vega-lite/v5.2.0.json"
}

hannahburkhardt avatar May 06 '22 02:05 hannahburkhardt