Skip to content

Conversation

@ylecarvalho
Copy link

@ylecarvalho ylecarvalho commented Nov 19, 2025

Description

This PR improve the speed to scroll and panning when is using DateTimeCategoryAxis

Ticket

Changes

Was created the _binarySearch helper function that is used the binary search algorithm to find the index in labels when is calling the updateXValues

Because the List.contains and List.indexOf uses 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.

Before After
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.contains and List.indexOf

Screen.Recording.2025-11-19.at.15.17.08.mov

@VijayakumarMariappan VijayakumarMariappan added charts Charts component open Open labels Nov 20, 2025
@Harsha-SF4223
Copy link

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
Harsha.

@VijayakumarMariappan VijayakumarMariappan added follow-up scheduled Follow-up scheduled performance Performance related and removed open Open labels Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

charts Charts component follow-up scheduled Follow-up scheduled performance Performance related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants