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

Improve hover performance #6716

Closed
benmccann opened this issue Nov 8, 2019 · 1 comment
Closed

Improve hover performance #6716

benmccann opened this issue Nov 8, 2019 · 1 comment

Comments

@benmccann
Copy link
Contributor

Thanks to @leeoniya for pointing out that hover performance isn't great. Chart.js does quite poorly on the uPlot benchmark which uses mode: 'index', intersect: false

The logic looks pretty suspect to me. It looks like it iterates over every single element from every dataset and computes the distance between the element and the mouse. At least in the x direction a much better thing to do would be to get the index for the corresponding value on the scale rather than computing over all data points. Even if in the worst case you had to compute the distance for every index, that'd still be 3x cheaper than computing for every data point (i.e. compute the nearest index once instead of once per dataset)

@benmccann
Copy link
Contributor Author

Fixed for the time scale in #6827. Other scales can be fixed by implementing getIndexForPixel that the time scale adds in that PR. Though that method perhaps should be moved to the controller because index is a concept of the dataset, which the scale does not have access to

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