Skip to main content

DataLabelOptions Interface

Contains data label options.

Namespace: DevExpress.Spreadsheet.Charts

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

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

public interface DataLabelOptions :
    DataLabelBase,
    ShapeFormat,
    ShapeFormatBase,
    ShapeTextFormat

The following members return DataLabelOptions objects:

Remarks

The DataLabelOptions interface contains specific settings for data labels displayed on a chart.

In addition to the properties inherited from the base DataLabelBase interface, the DataLabelOptions interface provides the DataLabelOptions.LeaderLines property that allows you to display leader lines connecting data labels with the corresponding data points in a chart.

To access an object exposing the DataLabelOptions interface, use the ChartView.DataLabels property, which allows modification of all data labels within a chart view. To adjust data labels of a particular series, use the Series.CustomDataLabels property. This property provides access to the DataLabelCollection object which inherits data label settings from the DataLabelOptions interface. To modify an individual data label, add a DataLabel object by its index to the data label collection and then change the desired properties of that object.

Example

The example below demonstrates how to create a pie chart and adjust the display settings of its data labels. In particular, set the DataLabelBase.ShowCategoryName and DataLabelBase.ShowPercent properties to true to display the category name and percentage value in a data label at the same time. To separate these items, assign a new line character to the DataLabelBase.Separator property, so the percentage value will be automatically wrapped to a new line.

View Example

Worksheet worksheet = workbook.Worksheets["chartTask1"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.Pie, worksheet["B2:C7"]);
chart.TopLeftCell = worksheet.Cells["E2"];
chart.BottomRightCell = worksheet.Cells["K15"];

// Display the category name and percentage.
DataLabelOptions dataLabels = chart.Views[0].DataLabels;
dataLabels.ShowCategoryName = true;
dataLabels.ShowPercent = true;
dataLabels.Separator = "\n";

// Set the chart style.
chart.Style = ChartStyle.ColorGradient;
// Hide the legend.
chart.Legend.Visible = false;
// Set the angle of the first pie-chart slice.
chart.Views[0].FirstSliceAngle = 100;
See Also