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, choose whether sorting should be performed by series point 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, it is possible to define the order in which automatically generated series objects are sorted within the chart control, based upon the series names.

Note

The names of the dynamically created series are taken from a data field specified by the ChartControl.SeriesDataMember property.

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

The property’s value Resulting image
SeriesSorting = None SeriesSorting_None
SeriesSorting = Ascending SeriesSorting_Ascending
SeriesSorting = Descending 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 (by the ChartControl.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 values.

SeriesPointsSortingKey

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

Property values

Resulting image

SeriesPointsSorting = None

SeriesPointsSortingKey = Value

SeriesPointSorting_none

SeriesPointsSorting = Ascending

SeriesPointsSortingKey = Value

SeriesPointSorting_ascend

SeriesPointsSorting = Descending

SeriesPointsSortingKey = Value

SeriesPointSorting_descend

See Also