Articles in this section

How to sort pivot calculation values in WinForms PivotChart?

The WinForms PivotChart control supports sorting of both PivotAxis and PivotLegends programmatically in the ascending and descending order. By default, the pivot chart populates the series in ascending order.

Sort by pivot axis

The PivotAxis can be sorted by adding PivotSortDescriptor to the SortedAxis collection and ListSortDirection to specify the sorting order.

The following sample sorts the pivot axis groups by their values for the axis field, here the axis field is Country and the order is Descending.

public Form1()
{
    InitializeComponent();
    this.InitializePivotChart();
    this.pivotChart1.SortedAxis.Add(new PivotSortDescriptor("Country", ListSortDirection.Descending));
}
Public Sub New()
    InitializeComponent()
    Me.InitializePivotChart()
    Me.pivotChart1.SortedAxis.Add(New PivotSortDescriptor("Country", ListSortDirection.Descending))
End Sub

Output

Before sorting


After sorting


Sort by pivot legends

The PivotLegends can be sorted by adding PivotSortDescriptor to the SortedLegends collection and ListSortDirection to specify the sorting order.

The following sample sorts the pivot legend (series) items by their values for the legend field, here the legend field is Date and the order is Descending.

public Form1()
{
    InitializeComponent();
    this.InitializePivotChart();
    this.pivotChart1.SortedLegends.Add(new PivotSortDescriptor("Date", ListSortDirection.Descending));
}
Public Sub New()
    InitializeComponent()
    Me.InitializePivotChart()
    Me.pivotChart1.SortedLegends.Add(New PivotSortDescriptor("Date", ListSortDirection.Descending))
End Sub
Output

Before sorting

After sorting

For more details refer to the WinForms PivotChart documentation page.

Conclusion

I hope you enjoyed learning about how to sort pivot calculation values in WinForms PivotChart.

You can refer to our WinForms Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our WinForms Chart examples to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied