Anthony-SMD opened a new pull request, #21900: URL: https://github.com/apache/echarts/pull/21900
## Brief Information This pull request is in the type of: - [ ] bug fixing - [ ] new feature - [x] others ### What does this PR do? `SeriesModel.indicesOfNearest` uses a binary search when the values of the dimension are in ascending order, in place of a scan of all the data. ### Fixed issues - #21899: Axis tooltip is slow with many series ## Details ### Before: What was the problem? With `tooltip.trigger: 'axis'`, each mouse move calls `indicesOfNearest` for each series, and each call scans all the data with one `axis.dataToCoord` for each point. On a time chart with 44 series (56,760 points), this took 3.1 ms of each mouse move. With 182 series (218,400 points), it took about 57 ms. ### After: How does it behave after the fixing? When the values of the dimension are in ascending order, a binary search finds the runs of equal values on each side of the target value, and only those indices go through the comparison. The comparison is the same code as before, so the result is the same: the value-in-the-middle rule and the equal-values rule do not change. The order is checked once for each data store and dimension (a store is replaced, not changed, except `appendData`, which changes its count). Data that is not in ascending order, or that contains NaN, uses the full scan as before. In the 44-series chart, `indicesOfNearest` takes 0.1 ms per mouse move (3.1 ms before). Unit tests compare the result with a full scan for ascending data, equal values, data not in order, one point, no points, an empty value, an inverse axis, `maxDistance`, and `appendData`. ## Document Info One of the following should be checked. - [x] This PR doesn't relate to document changes - [ ] The document should be updated later - [ ] The document changes have been made in apache/echarts-doc#xxx ## Misc ### Security Checking - [ ] This PR uses security-sensitive Web APIs. ### ZRender Changes - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx). ### Related test cases or examples to use the new APIs `test/ut/spec/model/seriesIndicesOfNearest.test.ts` ### Merging options - [x] Please squash the commits into a single one when merging. ### Other information -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
