- Home
- Forum
- Xamarin.Forms
- Series at Runtime
Series at Runtime
Hello,
I'm trying build a Sfchart with Series generated at Runtime, could give me some sample?
Thanks.
SIGN IN To post a reply.
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.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SimpleSample_(2)1773172618.zip
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.
Regards,
Saravanan.
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.
[XAML]:
|
<Button Text="Add Series Collection" Clicked="Button_Clicked" />
<chart:SfChart x:Name="chart" Series="{Binding ChartseriesCollection}" /> |
[C#]:
|
private void Button_Clicked(object sender, EventArgs e)
{
for(int i = 0; i < 5; i++)
{
GenerateSeries();
}
}
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:
Sample- https://www.syncfusion.com/downloads/support/directtrac/146706/ze/146706-sample-877340071.zip
Please refer the KB for more details
Regards,
Rachel.
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
RF Ramon Farizel
- Aug 14, 2019 08:36 PM UTC
- Aug 19, 2019 01:12 PM UTC