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

Series at Runtime

I'm trying build a Sfchart with Series generated at Runtime, could give me some sample?

3 Replies

SM Saravanan Madheswaran Syncfusion Team August 15, 2019 09:50 AM UTC

Hi Ramon, 
We have prepared sample to achieve your requirement that will be downloaded from below link. 
In that sample we have updated the series dynamically on button click and we modified the series data collection at every half second.  
Please refer the below link, if you try to update existing data point in the series.  
We hope the above information will help you. 

RF Ramon Farizel August 16, 2019 04:20 PM UTC

Hello Saravanan,

Thanks for attention, but this solution doesn't resolved my issue completly.

If i just follow this sample, my chart will be always with 2 Series. In my case I would like to generate at Runtime the quantity of series in my SFChart too. 

RA Rachel A Syncfusion Team August 19, 2019 01:12 PM UTC

Hi Ramon, 
You can achieve this requirement by adding series to ChartSeriesCollection and bind it to series property of chart. Please refer the below code. 
<Button Text="Add Series Collection" Clicked="Button_Clicked" /> 
<chart:SfChart x:Name="chart" Series="{Binding ChartseriesCollection}" /> 
private void Button_Clicked(object sender, EventArgs e) 
    for(int i = 0; i < 5; i++) 
private void GenerateSeries() 
   var random = new Random(); 
   var data = new ObservableCollection<ChartDataModel>(); 
   for (int i = 1; i < 5; i++) 
      data.Add(new ChartDataModel(i, random.Next(0, 80))); 
   viewModel.ChartseriesCollection.Add(SetupSeries(new LineSeries(), data)); 
private XyDataSeries SetupSeries(XyDataSeries series, IEnumerable itemSource) 
   series.ItemsSource = itemSource; 
   series.XBindingPath = "XValue"; 
   series.YBindingPath = "YValue"; 
   return series; 
We have prepared sample for your reference, and it can be downloaded from the below link: 
Please refer the KB for more details  

Live Chat Icon For mobile
Up arrow icon