Closed Justin-Terry closed 1 month ago
@Justin-Terry a very hacky way to resolve this issue is to add a key prop to the bar chart and ensure that the value changes each time a click is made. For instance, the title for the buttons, that you have, could be used. The key prop triggers the bar chart to rerender each time its value changes.
Hi @Justin-Terry 👋 Thanks for reporting this bug.
The issue with Bars not re-rendering on data change in case of non-animated chart has been fixed in version 1.4.18
Please use the latest version of the library.
Libraries Installed
Explanation
If the data in a bar chart is changed (one to several times) the chart begins to render the data incorrectly. When the chart is animated it takes several changes to surface the bug but the chart begins rendering some bars the wrong color and/or doesn't render them at all. If the chart is not animated then old data will remain on the chart.
The issue originally occurred for me using an Expo Dev Client build but the minimum reproduction proved it will also happen in Expo Go.
The same code works fine on iOS.
Screenshots
Android![Android](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/assets/43148991/3090c265-6d36-4bb2-8f49-d2fb19264cf6)
iOS![iOS](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/assets/43148991/15313cf5-7530-40e6-898a-3176049ce596)
Reproduction Videos
Animated https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/assets/43148991/3c62f11f-67c1-4c31-ab9a-cc2d20b94011
Not Animated https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/assets/43148991/3631eb84-8fda-4e37-bdbc-e5c125730325
Same code on iOS behaving as expected https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/assets/43148991/9f2f2f58-bb9f-4358-bca3-624a08a65f03
Reproduction Steps
I have a repository here: https://github.com/Justin-Terry/minimum-charts-repro
If you'd prefer to do it yourself, this is the component.