New to Telerik UI for WinUI? Download free 30-day trial

How to Generate a Dynamic Series Using a Collection of Collections

Examples 1, 2 and 3 demonstrate how to create a RadCartesianChart with a dynamic BarSeries.

Example 1: Defining the model

public class Data 
{ 
    public double Value { get; set; } 
 
    public string Category { get; set; } 
} 

Example 2: Populating with data

public MainPage() 
{ 
    this.InitializeComponent(); 
    List<List<Data>> collection = new List<List<Data>>(); 
    Random r = new Random(); 
 
    for (int i = 0; i < 5; i++) 
    { 
        List<Data> data = new List<Data>(); 
        data.Add(new Data { Category = "Apple", Value = r.Next(1, 20) }); 
        data.Add(new Data { Category = "Orange", Value = r.Next(1, 20) }); 
        data.Add(new Data { Category = "Lemon", Value = r.Next(1, 20) }); 
 
        collection.Add(data); 
    } 
 
    provider.Source = collection; 
 
} 

Example 3: Defining the RadCartesianChart and the ChartSeriesProvider

    <telerikChart:RadCartesianChart PaletteName="DefaultDark" > 
        <telerikChart:RadCartesianChart.HorizontalAxis> 
            <telerikChart:CategoricalAxis/> 
        </telerikChart:RadCartesianChart.HorizontalAxis> 
        <telerikChart:RadCartesianChart.VerticalAxis> 
            <telerikChart:LinearAxis/> 
        </telerikChart:RadCartesianChart.VerticalAxis> 
        <telerikChart:RadCartesianChart.SeriesProvider > 
            <telerikChart:ChartSeriesProvider x:Name="provider" > 
                <telerikChart:ChartSeriesProvider.SeriesDescriptors> 
                    <telerikChart:CategoricalSeriesDescriptor ValuePath="Value" CategoryPath="Category"> 
                        <telerikChart:CategoricalSeriesDescriptor.Style> 
                            <Style TargetType="telerikChart:BarSeries"> 
                                <Setter Property="CombineMode" Value="Cluster"/> 
                            </Style> 
                        </telerikChart:CategoricalSeriesDescriptor.Style> 
                    </telerikChart:CategoricalSeriesDescriptor> 
                </telerikChart:ChartSeriesProvider.SeriesDescriptors> 
            </telerikChart:ChartSeriesProvider> 
        </telerikChart:RadCartesianChart.SeriesProvider> 
    </telerikChart:RadCartesianChart> 

Figure 1: Result from Example 3

Dynamic Bar Series

In this article
Not finding the help you need?