Back to Devexpress

DataLabelBase.LabelPosition Property

officefileapi-devexpress-dot-spreadsheet-dot-charts-dot-datalabelbase-164a6eee.md

latest6.9 KB
Original Source

DataLabelBase.LabelPosition Property

Gets or sets the position of data labels on the chart.

Namespace : DevExpress.Spreadsheet.Charts

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
DataLabelPosition LabelPosition { get; set; }
vb
Property LabelPosition As DataLabelPosition

Property Value

TypeDescription
DataLabelPosition

A DataLabelPosition enumeration value specifying the data label placement.

|

Available values:

NameDescription
Default

Specifies that data labels should be displayed at the default location.

| | Left |

Specifies that data labels should be displayed to the left of the data markers.

| | Top |

Specifies that data labels should be displayed above the data markers.

| | Right |

Specifies that data labels should be displayed to the right of the data markers.

| | Bottom |

Specifies that data labels should be displayed below the data markers.

| | Center |

Specifies that data labels should be displayed in the center of the data markers.

| | BestFit |

Specifies that data labels should be displayed in the best location.

| | InsideBase |

Specifies that data labels should be displayed inside the base of the data markers.

| | InsideEnd |

Specifies that data labels should be displayed inside the end of the data markers.

| | OutsideEnd |

Specifies that data labels should be displayed outside the end of the data markers.

|

Example

The example below demonstrates how to create a clustered column chart, enable data labels, and specify their location using the DataLabelBase.LabelPosition property. This example centers data labels within columns.

View Example

csharp
Worksheet worksheet = workbook.Worksheets["chartTask3"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet["B2:D4"]);
chart.TopLeftCell = worksheet.Cells["H2"];
chart.BottomRightCell = worksheet.Cells["N14"];

// Display data labels and specify their position within the chart.
chart.Views[0].DataLabels.ShowValue = true;
chart.Views[0].DataLabels.LabelPosition = DataLabelPosition.Center;
vb
Dim worksheet As Worksheet = workbook.Worksheets("chartTask3")
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B2:D4"))
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")

' Display data labels and specify their position within the chart.
chart.Views(0).DataLabels.ShowValue = True
chart.Views(0).DataLabels.LabelPosition = DataLabelPosition.Center

The following code snippets (auto-collected from DevExpress Examples) contain references to the LabelPosition property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/CodeExamples/DataLabelsActions.cs#L39

csharp
chart.Views[0].DataLabels.ShowValue = true;
chart.Views[0].DataLabels.LabelPosition = DataLabelPosition.Center;

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/CodeExamples/DataLabelsActions.cs#L39

csharp
chart.Views[0].DataLabels.ShowValue = true;
chart.Views[0].DataLabels.LabelPosition = DataLabelPosition.Center;

spreadsheet-document-api-chart-examples/CS/SpreadsheetDocServerChartAPISamples/CodeExamples/DataLabelsActions.cs#L46

csharp
chart.Views[0].DataLabels.ShowValue = true;
chart.Views[0].DataLabels.LabelPosition = DataLabelPosition.Center;

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/CodeExamples/DataLabelsActions.vb#L43

vb
chart.Views(0).DataLabels.ShowValue = True
chart.Views(0).DataLabels.LabelPosition = DataLabelPosition.Center

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/CodeExamples/DataLabelsActions.vb#L42

vb
chart.Views(0).DataLabels.ShowValue = True
chart.Views(0).DataLabels.LabelPosition = DataLabelPosition.Center

spreadsheet-document-api-chart-examples/VB/SpreadsheetDocServerChartAPISamples/CodeExamples/DataLabelsActions.vb#L51

vb
chart.Views(0).DataLabels.ShowValue = True
            chart.Views(0).DataLabels.LabelPosition = DataLabelPosition.Center
#End Region ' #SetDataLabelsPosition

See Also

DataLabelBase Interface

DataLabelBase Members

DevExpress.Spreadsheet.Charts Namespace