track and restore series visibility

I have a SFCartesianChart wich shows periodically updating data by using the setState approach. Furthermore i do show a Legend where "toggleSeriesVisibility" is enabled. Now i would like to track and save which series the user has enabled/disabled by clicking the legend items. So when he wants to view the live-graph again later, the previous enabled/disabled series and legend state should be restored. Could you please provide a sample how to achieve this?


Regards,


Daniel


3 Replies 1 reply marked as answer

YG Yuvaraj Gajaraj Syncfusion Team December 15, 2021 02:00 PM UTC

Hi Daniel Wolf, 
 
Greetings from Syncfusion. We have analyzed your query and we would like to inform you that in default the state maintenance can’t be achieved when navigating to new page. However this can be achieved using a work around in which we have used onLegendTapped callback to get the toggled series index and when a legend is tapped and storing that series visibility globally. So, whenever you go and come back to the chart page, the state will be maintained based on the stored series visibility. We have also attached the sample below for your reference. 
 
  
Please check with the attached sample and revert us if you have further concern on this. 
 
Regards, 
Yuvaraj. 


Marked as answer

DW Daniel Wolf December 16, 2021 10:15 AM UTC

Hi Yuvaraj Gajaraj,


the sample works fine, thank you very much! I have tried this approach before and it was not working for me. I guess it has something todo wether im using the setState method for updating the data or UpdateDataSource.


Best regards,


Daniel



YG Yuvaraj Gajaraj Syncfusion Team December 17, 2021 03:05 PM UTC

Hi Daniel Wolf, 
 
Thanks for the update, we would like to let you know that while using the setState for updating the data source it will render the whole chart widget so it may performance related issues. So, we recommend to use the updateDataSource method to update the data source, this will process only the required points and few steps will be ignored like bound calculation, etc. We have also provided the UG link for your reference. 
 
 
Thanks, 
Yuvaraj. 


Loader.
Up arrow icon