)
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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to update an existing data point in Xamarin.Forms Chart?

Platform: Xamarin.Forms |
Control: SfChart |
Published Date: May 26, 2017 |
Last Revised Date: August 21, 2019

To update the existing data points dynamically, set the ListenPropertyChange property of ChartSeries to true to let the SfChart to listen the Model property changes. The default value of this property is false.

XAML:

<chart:SfChart.Series>
       <chart:ColumnSeries x:Name="series" ItemsSource="{Binding Data}" 
                           XBindingPath="Value" YBindingPath="Size" 
                           ListenPropertyChange="True">
       </chart:ColumnSeries>
</chart:SfChart.Series>

 

Also, Model class should be implemented the INotifyPropertyChanged. The following code example illustrates model class for a reference.

C#:

public class ChartDataModel : INotifyPropertyChanged
{
    public ChartDataModel(double value, double size)
    {
        Value = value;
        Size = size;
    }
 
    private double value;
 
    public double Value
    {
        get { return value; }
        set
        {
            this.value = value;
            RaisePropertyChanged("Value");
        }
     }
 
     private double size;
 
     public double Size
     {
         get { return size; }
         set
         {
              size = value;
              RaisePropertyChanged("Size");
         }
      }
 
      public event PropertyChangedEventHandler PropertyChanged;
 
      void RaisePropertyChanged(string name)
      {
           if (PropertyChanged != null)
               PropertyChanged(this, new PropertyChangedEventArgs(name));
      }
}

 

 

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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

Live Chat Icon For mobile
Live Chat Icon