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

dynamic series line width #403

Closed
leeoniya opened this issue Dec 15, 2020 · 1 comment
Closed

dynamic series line width #403

leeoniya opened this issue Dec 15, 2020 · 1 comment

Comments

@leeoniya
Copy link
Owner

#383 (comment)

Since you added the ability to specify stroke and fill as a function, i would like to also specify width as a function.
The reasoning is so that i can change the width when you hover over a series with focus.
If i have width 1, and i have a lot of series, i can't clearly see it, so i would like to change the width to 3 on focus, using a function on the width

@leeoniya
Copy link
Owner Author

this actually turns out to be rather tricky, since static and hovered point sizes are currently statically computed from line width. in addition, static point visibility depends on point density, which depends on point size. so it may turn out that hovering will hide the points because their new diameter causes them to become too dense (probably not a frequent case). also, uPlot does not currently mutate the hover point styling after initialization (only their position). doing dynamic width properly will add quite a bit of extra code, especially if we allow all width parameters to be dynamic in the rest of the API for consistency.

the ROI here is not worthwhile, IMO.

highcharts seems to ignore this and leaves the point diameters static: https://jsfiddle.net/ajupyxhv/

if you just want to alter the line width on focus (and ignore all the above), it's pretty simple to do this:

hooks: {
  setSeries: [
    (u, seriesIdx) => {
      console.log("focus!", seriesIdx);

      u.series.forEach((s, i) => {
        s.width = i == seriesIdx ? 2 : 1;
      });
    }
  ]
},

i've updated the demo with this sample: https://leeoniya.github.io/uPlot/demos/focus-cursor.html

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

1 participant