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

Allow inverting series highlight behavior: change only color/alpha of the hovered series #990

Open
juliusv opened this issue Aug 21, 2024 · 1 comment

Comments

@juliusv
Copy link

juliusv commented Aug 21, 2024

When focusing a series by hovering, the focus.alpha setting allows you to de-emphasize all other series by adding transparency to them. I find that effect a bit too visually jarring and would like to achieve the opposite, where only the series that is currently focused gets emphasized somehow, while all others keep their style. Ideally the emphasis wouldn't be alpha-based (since alpha is already 1), but would allow me to change the color or width of the series.

@juliusv
Copy link
Author

juliusv commented Aug 21, 2024

The one way I got this working with the current uPlot is by remembering the selected series index with a setSeries hook like this:

  let selectedSeriesIdx: number | null = null;

  // ...

      setSeries: [
        (u: uPlot, seriesIdx: number | null, _opts: Series) => {
          if (seriesIdx === selectedSeriesIdx) {
            return;
          }

          if (selectedSeriesIdx !== null) {
            u.series[selectedSeriesIdx].width = 1.5;
          }
          if (seriesIdx !== null) {
            u.series[seriesIdx].width = 2.2;
          }
          selectedSeriesIdx = seriesIdx;
          u.redraw();
        },
      ],

However, the required full redraw makes hovering sluggish when there are many series, so I probably won't be able to use this solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant