We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Data on the chart doesn't updat, even with ListenPropertyChange set to true


I'm testing SyncFusion sfChart control using your Getting Started documentation (https://help.syncfusion.com/uwp/sfchart/getting-started).
In the example there is Demands ObservableCollection that is displayed on tha chart. Unfortunately, the example works only if Demands collection is filled before chart is created. What if my data gets updated every second (or even faster)? I tried using ListenPropertyChanged, but that didn't help - chart is just empty.
Here's my code (it's the constructor of my Page):

        public IO_View()

            SfChart chart = new SfChart();

            chart.Header = "Demands Comparison";

            //Adding horizontal axis to the chart

            CategoryAxis primaryCategoryAxis = new CategoryAxis();

            primaryCategoryAxis.Header = "Demands";

            chart.PrimaryAxis = primaryCategoryAxis;

            //Adding vertical axis to the chart 

            NumericalAxis secondaryNumericalAxis = new NumericalAxis();

            secondaryNumericalAxis.Header = "Values";

            chart.SecondaryAxis = secondaryNumericalAxis;

            //Initialize the two series for SfChart
            ColumnSeries series1 = new ColumnSeries();

            series1.ItemsSource = this.Demands;

            series1.XBindingPath = "Demand";

            series1.YBindingPath = "Year2010";

            series1.ListenPropertyChange = true;

            ColumnSeries series2 = new ColumnSeries();

            series2.XBindingPath = "Demand";

            series2.YBindingPath = "Year2011";

            series2.ItemsSource = this.Demands;

            series2.ListenPropertyChange = true;

            //Adding Series to the Chart Series Collection


            //Adding Legends for the chart
            ChartLegend legend = new ChartLegend();

            chart.Legend = legend;

            //Setting Chart as a Content for the Grid in Page
            this.AnalogInputPI.Content = chart;

            //for chart:
            this.Demands = new ObservableCollection<GoldDemand>
                new GoldDemand()
                Demand = "Jewelry", Year2010 = 1998.0, Year2011 = 2361.2
                new GoldDemand()
                    Demand = "Electronics", Year2010 = 1284.0, Year2011 = 1328.0
                new GoldDemand()
                    Demand = "Research", Year2010 = 1090.5, Year2011 = 1032.0
                new GoldDemand()
                    Demand = "Investment", Year2010 = 1643.0, Year2011 = 1898.0
                new GoldDemand()
                    Demand = "Bank Purchases", Year2010 = 987.0, Year2011 = 887.0

4 Replies

MJ Marcin Jahn November 6, 2016 04:57 PM UTC

I'm still struggling to get this working. I tried implementing INotifyPropertyChanged, but it didn't change a thing. Is there a simple example showing how to update data dynamically? My sfChart still shows no data if I create the chart before filling the collection with numbers.

DA Devi Aruna Maharasi Murugan Syncfusion Team November 7, 2016 05:41 AM UTC

Hi Marcin, 
Thanks for contacting Syncfusion Support. 
We have prepared a demo sample based on your requirement (how to add the data dynamically) and it can be downloaded from below link, 
Sample: DynamicUpdate 

MJ Marcin Jahn November 7, 2016 09:22 PM UTC

Thank you very much!
Turns out, the only thing that was missing in my code was chart_Loaded event. Looks like data can be updated in the chart only when the chart fully loads on the page.
Thanks again for your help, I really appreciate it!

DA Devi Aruna Maharasi Murugan Syncfusion Team November 8, 2016 03:30 AM UTC

Hi Martin, 
Thanks for your update. 
Please let us know, if you need any further assistance. 

Live Chat Icon For mobile
Up arrow icon