Skip to main content
A newer version of this page is available. .

Sorting Data

  • 2 minutes to read

This document describes how to sort auto-created series or series points in an ascending or descending order, and in the case of series points, to choose whether sorting should be performed by the series points’ values or arguments. To learn more about a data point, its argument and value, refer to Charting Basics.

These sorting capabilities are detailed in the following sections:

Sorting Series

For auto-created series, its possible to define the order in which automatically generated series objects are sorted within the chart control, based upon the series names. Note that the names of the dynamically created series are taken from a data field specified by the WebChartControl.SeriesDataMember property.

So, to toggle between ascending and descending sort order of auto-created series, use the WebChartControl.SeriesSorting property. The following images demonstrate this property in action.

SeriesSorting = None SeriesSorting = Ascending SeriesSorting = Descending
SeriesSorting_None SeriesSorting_Ascending SeriesSorting_Descending

Note that the defined sorting affects the order of series within both a chart’s diagram, and its legend.

As for series that are manually added to a chart’s series collection (via the WebChartControl.Series property), it’s only possible to sort them at runtime, by managing their order within the collection.

Sorting Series Points

To sort data points of a series, use the SeriesBase.SeriesPointsSorting property. The SeriesBase.SeriesPointsSortingKey property determines whether series points should be sorted by their arguments or by values.

The following images demonstrate the three modes available for the SeriesBase.SeriesPointsSorting property, with the series points sorted by their values.

SeriesPointsSorting = None

SeriesPointsSortingKey = Value

SeriesPointsSorting = Ascending

SeriesPointsSortingKey = Value

SeriesPointsSorting = Descending

SeriesPointsSortingKey = Value

SeriesPointSorting_none

SeriesPointSorting_ascend

SeriesPointSorting_descend

See Also