Sorting Data

  • 2 minutes to read

This topic describes how to sort auto-created series or series points in ascending or descending order. Additionally, for series points, it explains how to choose whether to sort data by series point value or argument. To learn more about data points, arguments and values, refer to the following help topic: Charting Basics.

These sorting capabilities are detailed in the following sections:

Sorting Series

For auto-created series in the Chart Control, you can sort auto-generated series objects by series name. Note that dynamically created series names are taken from a data field specified by the WebChartControl.SeriesDataMember property.

To toggle between ascending and descending order for an 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 sort order affects series order in both the chart's diagram and legend.

Series that are manually added to a chart's series collection (via the WebChartControl.Series property) can only be sorted at runtime. You can manage the sort order within the collection.

Sorting Series Points

To sort series data points, use the SeriesBase.SeriesPointsSorting property. The SeriesBase.SeriesPointsSortingKey property determines whether series points should be sorted by argument or value.

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

SeriesPointsSorting = None

SeriesPointsSortingKey = Value

SeriesPointsSorting = Ascending

SeriesPointsSortingKey = Value

SeriesPointsSorting = Descending

SeriesPointsSortingKey = Value




See Also