Back to Devexpress

SeriesBase.SeriesPointsSorting Property

corelibraries-devexpress-dot-xtracharts-dot-seriesbase-13c615b4.md

latest7.7 KB
Original Source

SeriesBase.SeriesPointsSorting Property

Gets or sets the sort order of the series’ points.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public SortingMode SeriesPointsSorting { get; set; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property SeriesPointsSorting As SortingMode

Property Value

TypeDescription
SortingMode

A SortingMode enumeration value.

|

Available values:

NameDescription
None

The values are not sorted.

| | Ascending |

The values are sorted in ascending order.

| | Descending |

The values are sorted in descending order.

|

Remarks

The Chart Control can sort series points based on their arguments or data values, specified in the SeriesBase.SeriesPointsSortingKey property. Use the SeriesPointsSorting property to choose the sort mode for data points.

When there are multiple series with the same arguments in the chart’s collection, and a sort order is applied to one of these series, points are sorted within all series.

Note

If series have different point arguments, the Chart Control sorts points within a single series only. Use the QualitativeScaleComparer to sort all series in this case.

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

|

SeriesPointsSorting = None

|

SeriesPointsSorting = Ascending

SeriesPointsSortingKey = Value_1

|

SeriesPointsSorting = Descending

SeriesPointsSortingKey = Value_1

| | --- | --- | --- | |

|

|

|

For more information, refer to the following help topic: Sorting Data.

Example

The following properties allow you to sort series points within a series.

PropertyDescription
SeriesBase.SeriesPointsSortingKeySpecifies the point sort order.
SeriesBase.SeriesPointsSortingSpecifies the value by which series points should be sorted.
csharp
using DevExpress.XtraCharts;
using System;
using System.Windows.Forms;

namespace SeriesPointsSorting {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        #region #SeriesPointSorting
        private void Form1_Load(object sender, EventArgs e) {
            this.gSPTableAdapter.Fill(this.gspDataSet.GSP);

            SeriesBase seriesTemplate = chart.SeriesTemplate;
            seriesTemplate.SeriesPointsSorting = SortingMode.Ascending;
            seriesTemplate.SeriesPointsSortingKey = SeriesPointKey.Value_1;
        }
        #endregion #SeriesPointSorting
    }
}
vb
Imports DevExpress.XtraCharts
Imports System
Imports System.Windows.Forms

Namespace SeriesPointsSorting
    Partial Public Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        #Region "#SeriesPointSorting"
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            Me.gSPTableAdapter.Fill(Me.gspDataSet.GSP)

            Dim seriesTemplate As SeriesBase = chart.SeriesTemplate
            seriesTemplate.SeriesPointsSorting = SortingMode.Ascending
            seriesTemplate.SeriesPointsSortingKey = SeriesPointKey.Value_1
        End Sub
        #End Region ' #SeriesPointSorting
    End Class
End Namespace

The following code snippets (auto-collected from DevExpress Examples) contain references to the SeriesPointsSorting property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-visualize-data-grid-rows-in-a-chart/CS/ControlRowSourceSample/MainForm.cs#L31

csharp
seriesTemplate.CrosshairLabelPattern = "{S}: {V:C2}";
seriesTemplate.SeriesPointsSorting = SortingMode.Descending;
seriesTemplate.SeriesPointsSortingKey = SeriesPointKey.Value_1;

winforms-chart-draw-a-custom-legend-marker-for-a-series-point/CS/CustomSeriesPointDrawingSample/Form1.cs#L54

csharp
chart.SeriesTemplate.ToolTipPointPattern = "{S}: {A} ({VP:P})";
    chart.SeriesTemplate.SeriesPointsSorting = SortingMode.Ascending;
}

winforms-visualize-data-grid-rows-in-a-chart/VB/ControlRowSourceSample/MainForm.vb#L29

vb
seriesTemplate.CrosshairLabelPattern = "{S}: {V:C2}"
seriesTemplate.SeriesPointsSorting = SortingMode.Descending
seriesTemplate.SeriesPointsSortingKey = SeriesPointKey.Value_1

winforms-chart-draw-a-custom-legend-marker-for-a-series-point/VB/CustomSeriesPointDrawingSample/Form1.vb#L58

vb
Me.chart.SeriesTemplate.ToolTipPointPattern = "{S}: {A} ({VP:P})"
    Me.chart.SeriesTemplate.SeriesPointsSorting = DevExpress.XtraCharts.SortingMode.Ascending
End Sub

winforms-chart-create-a-doughnut-chart/VB/Series_DoughnutChart/Form1.vb#L33

vb
' Specify how series points are sorted.
series1.SeriesPointsSorting = SortingMode.Ascending
series1.SeriesPointsSortingKey = SeriesPointKey.Argument

See Also

SeriesPointsSortingKey

Sorting Data

SeriesBase Class

SeriesBase Members

DevExpress.XtraCharts Namespace