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

How to generate series based on common items source?

Platform: UWP |
Control: SfChart |
Published Date: March 22, 2017 |
Last Revised Date: March 6, 2018


This article describes how to generate dynamic number of series by binding a collection (items source) directly to chart.


The solution for achieving this scenario is quite easy. It can be achieved by extending the SfChart (inheriting SfChart), and providing it with the SeriesTemplate (for customizing series type and its properties) and Source properties.

The implementation process is explained in the following steps:

Step 1: Define chart’s view model setup.

This step describes how to define the chart’s collection (items source) through MVVM.






View Model



Step 2: Implement the SfChart extension.

To achieve this requirement, we must use custom SfChart, which inherits from SfChart, and defines the following two properties: Source and SeriesTemplate.


The Source property is used to bind the items source (collection of collections) to chart. The chart series will be generated per item in the collection.




The SeriesTemplate property is used to define the type and visual appearance of chart series. This template is more flexible; it allows us to define any type of series and all its properties since the content of the template is series.



The following code illustrates generating dynamic number of series based on data (collection).





The following column chart illustrates the result of above code.


To generate different types of chart series

We can generate multiple types of series by using the DataTemplateSelector property. A new class of SeriesDataTemplateSelector can be created by inheriting the DataTemplateSelector property.



SfChart extension with SeriesTemplateSelector:

The SeriesTemplateSelector property is used to select the different series templates in single chart based on items.



SeriesDataTemplateSelector definition:

The different types of templates are defined in the resources for the SeriesTemplateSelector property.



The following column and line series (multiple series) illustrates the result of above codes.


Please find the required sample from this link.

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.

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