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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

127249 Nov 5,2016 11:32 AM UTC Nov 8,2016 03:30 AM UTC UWP 4
loading
Tags: SfChart
Marcin Jahn
Asked On November 5, 2016 11:32 AM UTC

Hi,

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()
        {
            this.InitializeComponent();

            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
            chart.Series.Add(series1);

            chart.Series.Add(series2);


            //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
                }
            };
        }

Marcin Jahn
Replied On 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.

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On 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 
  
Regards, 
Devi 




Marcin Jahn
Replied On 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!

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On November 8, 2016 03:30 AM UTC

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;