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

DateTime Grouping

When using the standard ChartGroupDescriptor, it is hard to group the data depending on a DateTime field. For example if you want to group the data by month or by year, or even by day, it would be quite impossible. In order to bring this out of the box the RadChart provides you with a set of group descriptors that are capable to group the data via a DateTime field.

You have the following descriptors at your disposal:

  • ChartSecondGroupDescriptor

  • ChartMinuteGroupDescriptor

  • ChartHourGroupDescriptor

  • ChartDayGroupDescriptor

  • ChartMonthGroupDescriptor

  • ChartYearGroupDescriptor

The name of each of the descriptors implies with which part of the DateTime field it is working. For example if you want to group tour data by year you have to use the ChartYearGroupDescriptor.

In order to use properly these descriptors you just have to set the appropriate DateTime field to their Member property. For example if you have a business object with a DateTime field called Date, you should have the following definition:

<telerik:RadChart x:Name="radPieChart"> 
    <telerik:RadChart.SeriesMappings> 
        <telerik:SeriesMapping> 
            <telerik:SeriesMapping.SeriesDefinition> 
                <telerik:LineSeriesDefinition /> 
            </telerik:SeriesMapping.SeriesDefinition> 
            <telerik:SeriesMapping.GroupingSettings> 
                <telerik:GroupingSettings> 
                    <telerik:GroupingSettings.GroupDescriptors> 
                        <telerik:ChartYearGroupDescriptor Member="Date" /> 
                    </telerik:GroupingSettings.GroupDescriptors> 
                </telerik:GroupingSettings> 
            </telerik:SeriesMapping.GroupingSettings> 
            <telerik:SeriesMapping.ItemMappings> 
                <telerik:ItemMapping DataPointMember="XValue" FieldName="Date" /> 
                <telerik:ItemMapping DataPointMember="YValue" FieldName="Value" /> 
            </telerik:SeriesMapping.ItemMappings> 
        </telerik:SeriesMapping> 
    </telerik:RadChart.SeriesMappings> 
</telerik:RadChart> 

WPF RadChart

In this article