ChartSeriesController has incorrect series index when rearranging the order of series

In our app, we have a feature to reorder/rearrange the order that multiple FastLineSeries display on the graph. That way the user can decide which series should render above the others. We have a list of all the graph's series, and update that series list in the order that the user is requesting, followed by setState. This works well, however, we also have a map of all the series' controllers, and those controllers now are storing the incorrect index value (controller.seriesRenderer.index). As we display multiple graphs on the screen, we have a custom set visibility function which can turn off particular series in all the graphs via looking up the series name in the controllers map, and setting each of those controllers 'isVisible' to true/false. This is where the problem occurs as each of the series' controllers still has the series original index before the series was reordered to a different index. So then even though the correct series controller is being called, it sets the visibility state of another series that is now in the index of where that series originally was.

Is there someway that I can update the controllers cached data? Or is there a better way to go about reordering series on a graph that will not run into this problem?

Thanks in advance


3 Replies 1 reply marked as answer

SM Saravanan Madheswaran Syncfusion Team September 2, 2025 05:21 PM UTC

 We have analyzed your query and would like to inform you that the issue arises due to how widget state is managed internally. When the chart series are reordered, the existing ChartSeriesController instances retain state tied to their original widget positions, which leads to incorrect behavior when toggling visibility. To resolve this, we recommend assigning a new Key to the chart widget whenever the series order is updated. This forces the chart to rebuild from scratch, ensuring that each series and its controller are correctly reinitialized according to the new order, thereby maintaining accurate visibility control. We have also shared a simple sample that demonstrates this behavior, along with its output with and without using a key, to help you better understand the impact and solution.


Attachment: fr197418_cf43525d.zip


Marked as answer

SD Software Developer replied to Saravanan Madheswaran September 3, 2025 04:42 AM UTC

Thanks! That works perfectly! I very much appreciate it!



MR Mugunthan Ramalingam Syncfusion Team September 3, 2025 05:40 AM UTC

Hi Software Developer,

 

Most Welcome. Kindly get back to us if you have further queries. We are always happy to assist you.

 

Regards,

Mugunthan.


Loader.
Up arrow icon