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
close icon

Refreshing chart on Save

I have an sfChart for Xamarin forms.

How do I add a new value, click a save button and have the chart refreshed.

This is my ViewModel

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using BeatPain.Database;
using System.Linq;

namespace BeatPain
    public class PainScoreViewModel

        public RewardDatabase database;

        public ObservableCollection<PainScoreDB> Items { getset; }
        public PainScoreViewModel()
            database = new RewardDatabase();
            Items = new ObservableCollection<PainScoreDB>();

                   var items = (from i in database.GetItems<PainScoreDB>()
                orderby i.PainDateSetDB
                select i);

                foreach (var item in items)

My chart XAML

<chart:SfChart Grid.Row="6" x:Name="painChart">







                <chart:NumericalAxis Minimum="0" Maximum="10" Interval="1">

                 <chart:ChartAxisTitle Text="Pain Score"></chart:ChartAxisTitle>



         <chart:ColumnSeries ItemsSource="{Binding Items}" XBindingPath="PainDateSetDB" YBindingPath="ScoreDB" Color="{StaticResource PositiveBackgroundColorUnselected}"

            <chart:ChartColorModel Palette="None"/>



    <chart:ChartDataMarker ShowLabel="True"/>





I have attached a screen shot.  What I wish to do, is change the range, click on the save button, and for the chart on the same page to be refreshed.


Attachment: Screen_Shot_20170824_at_11.23.28_am_72799400.zip

1 Reply

SG Sivaram Ganesan Syncfusion Team August 24, 2017 10:23 AM UTC

Hi Julie,

Thanks for contacting Syncfusion support.

Chart will be automatically refreshed if we add, remove, insert and clear the data from ItemsSource at any time if the data is type of ObservableCollection.

We have prepared a sample based on this and it can be downloaded from below location.

Sample link: http://www.syncfusion.com/downloads/support/forum/132273/ze/ItemsSourceSample1256786745

Please get back to us on further assistance on this.


Live Chat Icon For mobile
Up arrow icon