-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
[FEATURE] Intersect frequency option for performance improvement #3757
Comments
@skogar42 one option is the timer but I don't think that should live in the core. The main event handler is https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js#L609 |
Another possibility could be store the last processed timestamp, and only update if the current timestamp exceeds the last timestamp + frequency period. Could this fit somewhere in tooltip.handleEvent()? |
@skogar42 yes, that could fit in there. I like it since it avoids the timer (which causes battery life issues and generally means something else is wrong architecturally). Another option is to throttle in a way similar to how resize events are throttled: https://github.com/chartjs/Chart.js/blob/master/src/core/core.helpers.js#L972 What I would do here would be:
I think you might want to skip the throttling if the event type changes. But if you had 4 quick events in the order: |
Thanks for the suggestion! I'll take a closer look at the resize listener and see what I can do. |
Done in #6953 |
Context
I have a line chart that displays a hiking elevation profile with many points. For the tooltip, I am using mode = "x" and intersect = "false". I am experiencing high CPU utilization when I move the mouse around constantly.
Expected Behavior
It would be nice to have a frequency option that can throttle how often the mouseover gets processed.
Possible Solution
One possible way to implement this is to have a timer set to the frequency that sets an okToUpdate flag. Whenever the mouseover happens, check if it is okToUpdate, otherwise ignore the mouseover. I'm not familiar with the design enough to know which object is the best place to add the option.
I would be willing to work on this if someone could give me some pointers on where in the source would be the best place to add this.
Environment
The text was updated successfully, but these errors were encountered: