Version

Swap Rows and Columns

This topic gives an overview of the SwapRowsAndColumns property. It is assumed that the chart is connected to a data source that has one or more records.

The SwapRowsAndColumns property will change the data source so that the columns of the table become rows and the rows become columns. This is useful if the data is stored in a different manner from the one in which you wish to display it, or if you want to be able to provide two different ways of analyzing the data.

For example, when the ChartType property is set to ColumnChart , the same values for the columns will be used, but they will be displayed in a different order when the SwapRowsAndColumns property is set to True. With the property set to True, the original columns will be displayed as the series, and the rows will be displayed as the items displayed in the series.

The example code below demonstrates how to swap rows and columns.

In Visual Basic:

Private Sub SwapRowsandColumns_Load(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles MyBase.Load
	Me.UltraChart1.Data.SwapRowsAndColumns = True
End Sub

In C#:

private void SwapRowsandColumns_Load(object sender, System.EventArgs e)
{
	this.ultraChart1.Data.SwapRowsAndColumns = true;
}

Composite charts have a similar facility to toggle the way data is grouped. For each chart layer, toggle the ChartLayerAppearance.SwapRowsAndColumns property to swap the grouping of Series and DataPoints.

image::images/Chart_ChartLayer_Swap_Rows_and_Columns_01.png[Shows a standard 2D Column Chart with SwapRowsAndColumns set to False.]

SwapRowsAndColumns = False

Shows the same 2D Column Chart as above

SwapRowsAndColumns = True