Updates to FlexChart's ItemSource does not update chart visuals

Posted by: nick.bova on 6 July 2021, 11:46 pm EST

    • Post Options:
    • Link

    Posted 6 July 2021, 11:46 pm EST

    I have live data that I’m trying to read from several source devices. I have to read from a list of devices and determine which data channels they support at runtime, so in order to display their data in the FlexChart, I create and add new series to the FlexChart for each channel in code behind, and I set the ItemSource and Binding per series rather than for the FlexChart itself.

    I want the data on the graphs to update in realtime with data streamed from my devices. I have tried several different methods of updating the ItemSource’s collection as well as updating the ItemSource and Bindings with new instances of my source data collection. The only thing that’s worked as far as getting the charts to update properly is to remove all of the series from the FlexChart and add them again with new data. This ends up being very CPU intensive and wasteful, so it is not ideal.

    I keep a dictionary of each of the chart Series based on channel name. I’m able to update other properties in the series (such as Visibility) by referencing them from this dictionary just fine. The updates to the ItemSource do seem to otherwise work (Looking at the FlexChart in the Visual Studio debugger, the new data is set to each Series item source), it’s just that the updates to the ItemSource don’t trigger the chart to update with the new data. Is there anyway to force this to happen? Is there an alternative to what I’m trying to achieve?

  • Posted 7 July 2021, 4:30 pm EST

    Hi Nick,

    Thank you for sharing the detailed description.

    In order to display live data in FlexChart, you need to use an ItemsSource which can provide notifications related to data update. For example, you can use an ObservableCollection as Series’s ItemsSource which provides a notification whenever an item is added/removed.

    So, that way you don’t have to remove/add series. You can simply add the new data item to the ObservableCollection and it will be reflected in the FlexChart UI.

    Please refer to the attached sample which shows live data streaming using an ObservableCollection with FlexChart. (see FlexChartRealtime.zip)

    Best Regards,

    Kartik

    FlexChartRealtime.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels