Edit this page

Sorting

This feature is available in data bound scenarios only!

The RadChart allows you to programmatically sort its data. This is achieved via the SortDescriptors property of the RadChart or the SortDescriptors property of the SeriesMapping. This collection allows you to use descriptors which define the sorting member and the sorting direction for the data to which the RadChart is bound. As this is a collection, you are able not only to add, but to remove or clear the entries in it, too.

The items in this collection are of type ChartSortDescriptor. It exposes two important properties:

  • Member - defines the property of the data object, by which the data will be sorted.

  • SortDirection - defines the sorting direction.

Basically the sorting in the context of the RadChart represents the way in which the data points are connected. For example, if you have a LineSeriesDefinition and you define an ascending sorting, the line will connect the points in ascending order.

Here is an example of a chart without sorting descriptors.

Here is an example of implementing sorting.

To use the ChartSortDescriptors in XAML you have to declare the following namespace:

<!--  xmlns:telerikCharting="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting"  -->

<telerik:RadChart x:Name="radChart">
    <telerik:RadChart.SortDescriptors>
        <telerik:ChartSortDescriptor Member="Quantity" SortDirection="Ascending" />
    </telerik:RadChart.SortDescriptors>
</telerik:RadChart>

ChartSortDescriptor descriptor = new ChartSortDescriptor();
descriptor.Member = "Title";
descriptor.SortDirection = ListSortDirection.Ascending;
this.radChart.SortDescriptors.Add(descriptor);
Dim descriptor As New ChartSortDescriptor()
descriptor.Member = "Title"
descriptor.SortDirection = ListSortDirection.Ascending
Me.radChart.SortDescriptors.Add(descriptor)

Here is a snapshot of the result.

Was this article helpful? Yes No

Give article feedback

Tell us how we can improve this article

Dummy