Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouseover and Legend selections don't work together #7907

Closed
mershal opened this issue Jan 6, 2022 · 1 comment
Closed

Mouseover and Legend selections don't work together #7907

mershal opened this issue Jan 6, 2022 · 1 comment

Comments

@mershal
Copy link

mershal commented Jan 6, 2022

Quick overview of the issue

I want one chart that does 2 things:

  1. Hovering a bar should change its opacity
  2. Clicking on a legend item reduces the opacity of all the unselected items

For this, I created 2 selection params and used them in fillOpacity condition.
The error starts when I first click a legend item, and then when I hover the legend.

The error is:
TypeError: Cannot read properties of undefined (reading '0')

After this error the entire chart go nuts:

  1. I need to double click a legend item to select it (instead of a single click)
  2. Clicking on a bar (might) change the selected legend item
  3. Hovering a bar doesn't always change its opacity
  4. And maybe some other stuff

Simple spec to reproduce the issue

Example in Vega Editor

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {"category": "A", "value": 1},
      {"category": "B", "value": 2},
      {"category": "C", "value": 3}
    ]
  },
  "params": [
    {"name": "hover", "select": {"type": "point", "on": "mouseover"}},
    {
      "name": "legend",
      "select": {"type": "point", "fields": ["category"]},
      "bind": "legend"
    }
  ],
  "mark": {"type": "bar"},
  "encoding": {
    "x": {"field": "category", "type": "ordinal"},
    "y": {"field": "value", "type": "quantitative"},
    "fillOpacity": {
      "condition": [
        {"param": "legend", "value": 1},
        {"param": "hover", "value": 0.6, "empty": false}
      ],
      "value": 0.2
    },
    "color": {"field": "category"}
  }
}

Screenshot of the error

image

Any quick solutions?
Thanks!

@arvind
Copy link
Member

arvind commented Jul 8, 2022

Thanks for filing this issue @mershal! This should be fixed as of #8268.

@arvind arvind closed this as completed Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants