DataLabelCollection.SetReference(CellRange) Method
Specifies the cell range used as a source for the data labels.
Namespace: DevExpress.Spreadsheet.Charts
Assembly: DevExpress.Spreadsheet.v24.1.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
range | CellRange | A cell range used as a reference to data labels. |
Exceptions
Type | Description |
---|---|
InvalidOperationException | Thrown if the passed range is a 2D range (contains more than one row and/or column). |
ArgumentException | Thrown if the passed range is a union (complex) range. |
Remarks
Set the Series.UseCustomDataLabels property to true
to specify cell values as data labels.
Example
The code sample below shows how to use cell values as data labels:
using DevExpress.Spreadsheet;
using DevExpress.Spreadsheet.Charts;
Worksheet worksheet = workbook.Worksheets["chartTask5"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Create a chart and specify its location
Chart chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet["B2:C8"]);
chart.TopLeftCell = worksheet.Cells["F2"];
chart.BottomRightCell = worksheet.Cells["L15"];
// Specify the chart style
chart.Style = ChartStyle.ColorGradient;
chart.Series[0].UseCustomDataLabels = true;
var customDataLabels = chart.Series[0].CustomDataLabels;
customDataLabels.SetReference(worksheet["D3:D8"]);
See Also