Regression in 28.1.36 - Zooming broken after SfCartesianChart data source changes on widget
Using Flutter 3.27, I have observed a regression from version 28.1.35 to version 28.1.36 of syncfusion_flutter_charts, where zooming no longer works on a SfCartesianChart after the data source on that chart changes but the zoomPanBehavior value passed to it does not.
My application is using a riverpod provider to create a ZoomPanBehavior that is used in a SfCartesianChart:
static final zoomPanStateProvider = Provider
This ZoomPanBehavior object is then used as input to a SfCartesianChart widget. The data source for this chart can change over time. When the application first loads, with the first data source, zooming works as expected. But then with version 28.1.36 of the package, after the data source changes, zooming no longer works. I also tried version 28.1.38 and it is broken. It *does* work fine on version 28.1.35 (and the same code also worked fine with Flutter 3.24 and package version 27.2.5).
With the debugger I tracked down why zooming is not working after the data source changes with version >= 28.1.36:
- When the widget is first loaded with first data source, the zoomPanBehavior object parentBox property is set to non-null when the RenderBehaviorArea is mounted.
- Then when the data source of the chart changes, flutter calls updateChild, and since widget returns canUpdate returns false, flutter detaches and sets zoomPanBehavior to null as part of RenderBehaviorArea.detach as part of Element.deactivateChild during Element.updateChild.
- In the same frame as when the data source changes, the zoomPanBehavior parentBox property is set to non-null again as part of the mounting of the RenderBehaviorArea.
- However, here is the problem: in the same frame as when the data source changes, and *after* step 3, as part of RenderBehaviorArea being disposed during RenderObjectElement being unmounted, the zoomPanBehavior property is set to NULL again.
void _zoomInAndOut(double zoomLevel, {Offset? origin}) { final RenderBehaviorArea? parent = parentBox as RenderBehaviorArea?;
if (parent == null) {
return;
}
Attachment: chartbrokenzoomingregression_e09b5dab.zip
Hi KD,
We have checked the reported 'Zooming not working after chart data source updated' issue at our end, and tried to replicate it in the 28.1.36 version of SfCartesianChart by,
1. Ensured zooming with update data source using ChartSeriesController.
2. Ensured zooming with update data source in setState.
3. Ensured zooming with update data source in new Navigation Page with Button click.
4. Ensured pinch and mouse wheel zooming
However, we were unable to reproduce it on our end. Please check the attached sample, and if you are still experiencing the issue, we kindly request you to share us with more information on your requirement in detail along with screenshots/screen recordings so that it will help us assist you in a better way.
Regards,
Baranibharathi P.
Attachment: FM_195717_4c67177c.zip
Thanks for your collaboration. I've found a simpler way to reproduce the issue. It doesn't actually appear to be related to changing the data source, but causing the widget to be replaced in the flutter state tree, which can most easily be caused by changing the key on the SfCartesianChart widget. I've attached a minimal example that no longer changes the data source but reproduces the issue...
Before hitting the "Change Widget Key" you can do zooming without issue. After hitting the "Change Widget Key" then zooming no longer works.
The issue does occurs on versions >= 28.1.36 and does not occur on version 28.1.35 and earlier.
Attachment: FM195717_v2_bc91daa8.zip
Hi KD,
We can replicate the reported issue regarding zooming is not working properly after updating the key. We have fixed and included the changes in our weekly patch release which is expected to be rolled out on Jan 21, 2025. We will update you here once the release is rolled out and we appreciate your patience until then.
Regards,
Aswini S.
Hi KD,
The reported issue has been fixed and rolled out in our weekly patch release on January 21, 2025. So, we kindly request you to upgrade the syncfusion_flutter_charts package to the latest version below.
Version: https://pub.dev/packages/syncfusion_flutter_charts/versions/28.1.41
Root cause: Handling null for the behavior's parent box in the dispose method prevents the chart's zoom functionality from updating when the chart key changes dynamically.
Regards,
Aswini S.
- 4 Replies
- 3 Participants
-
KD KD
- Jan 8, 2025 11:33 PM UTC
- Jan 21, 2025 06:54 AM UTC