All docs
V21.1
21.2 (EAP/Beta)
21.1
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

ChartObject.SelectData(CellRange) Method

Specifies the source data for the chart.

Namespace: DevExpress.Spreadsheet.Charts

Assembly: DevExpress.Spreadsheet.v21.1.Core.dll

Declaration

void SelectData(
    CellRange range
)

Parameters

Name Type Description
range CellRange

A continuous cell range that contains chart data.

Remarks

The SelectData method retrieves data series from the specified range and automatically determines the Series.SeriesName, Series.Arguments and Series.Values for each series. The method automatically determines whether the series data are in rows or in columns.

If the number of rows in a range is greater than the number of columns, the series data are in rows, therefore the rows are placed on the argument (horizontal) axis. If the number of columns is greater than the number of rows, the columns are placed on the argument axis. If the number of rows and columns are equal, the columns are placed on the horizontal axis. To switch rows to columns in the chart, use the ChartObject.SwitchRowColumn method.

This example demonstrates how to create a chart and specify its data using the ChartObject.SelectData method.

The data range looks as follows.

SelectDataExample_Range

The direction in which the data are extracted is specified by the parameter passed to the method. If the direction equals the ChartDataDirection.Row value, the following chart is displayed.

SelectDataExample_ChartByRow

If the direction equals the ChartDataDirection.Column value, the chart looks as follows.

SelectDataExample_ChartByColumn

Dim worksheet As Worksheet = workbook.Worksheets("chartTask3")
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a chart and specify its location.
Dim chartRowData As Chart = worksheet.Charts.Add(ChartType.ColumnClustered)
chartRowData.TopLeftCell = worksheet.Cells("D3")
chartRowData.BottomRightCell = worksheet.Cells("I14")

' Select chart data by rows.
chartRowData.SelectData(worksheet("B2:F6"), ChartDataDirection.Row)

' Create a chart and specify its location.
Dim chartColumnData As Chart = worksheet.Charts.Add(ChartType.ColumnClustered)
chartColumnData.TopLeftCell = worksheet.Cells("K3")
chartColumnData.BottomRightCell = worksheet.Cells("N14")

' Select chart data by columns.
chartColumnData.SelectData(worksheet("B2:F6"), ChartDataDirection.Column)
See Also