feat: Optimized index lookup in DateTimeCategoryAxis using binary search#2467
Conversation
- Added `_binarySearch` helper method.
|
Hi Yle Tractian, Thank you for your interest in improving the control and for taking the time to provide a solution. We truly appreciate your effort in creating the pull request and sharing the test code. We will need some additional time to validate the changes thoroughly. This includes running performance-related test cases to ensure the fix works well across different scenarios. Once the validation is complete, we will consider merging at any of our upcoming releases. As a note, while our Flutter chart source is openly available on GitHub for transparency, we currently do not accept direct contributions to the repository. This helps us maintain consistency and quality across releases. However, your feedback and suggestions are always welcome, and we encourage you to continue sharing ideas through our support channels. Thank you for your patience and contribution! Regards |
|
Hello @Harsha-SF4223 ! There are any updates on this optimization in sync fusion library? |
|
Hello @Harsha-SF4223! Happy new year! any updates on this optimization? It is really important for my company Tractian. |
Description
This PR improve the speed to scroll and panning when is using
DateTimeCategoryAxisTicket
Changes
Was created the
_binarySearchhelper function that is used the binary search algorithm to find the index in labels when is calling theupdateXValuesBecause the
List.containsandList.indexOfuses linear search that is On, so in large datasets is really slow. The binary search is O(log n) a lot of faster, and only requires the data to be sorted, what isn't a problem because it's a DateTime axis so the data will always be sorted.Testing
To test you can create an example chart using
DateTimeCategoryAxis, and compare the chart generate with this code with the master branch.Screen.Recording.2025-11-19.at.14.22.23.mov
Screen.Recording.2025-11-19.at.14.29.37.mov
How I find this problem
Looking in CPU profiler in dev tools, I found that 80% of the time was spent using
List.containsandList.indexOfScreen.Recording.2025-11-19.at.15.17.08.mov