Back to Devexpress

DataLabelBase.Separator Property

officefileapi-devexpress-dot-spreadsheet-dot-charts-dot-datalabelbase-2031491b.md

latest6.3 KB
Original Source

DataLabelBase.Separator Property

Gets or sets the string value that represents a separator for different items displayed in a data label.

Namespace : DevExpress.Spreadsheet.Charts

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
string Separator { get; set; }
vb
Property Separator As String

Property Value

TypeDescription
String

A string used as a separator.

|

Remarks

Use the Separator property to separate each item (such as the category name, series name, data point value or percentage value) in a data label with a comma, semicolon, new line character or any other text value you specify.

Example

The example below demonstrates how to create a pie chart and adjust display settings of its data labels. Set the DataLabelBase.ShowCategoryName and DataLabelBase.ShowPercent properties to true to display both category names and percentage values in data labels. To separate these entries, assign a new line character to the DataLabelBase.Separator property. The percentage value appears on a separate line.

View Example

csharp
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;
vb
Dim worksheet As Worksheet = workbook.Worksheets("chartTask1")
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a chart and specify its location.
Dim chart As 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.
Dim dataLabels As DataLabelOptions = chart.Views(0).DataLabels
dataLabels.ShowCategoryName = True
dataLabels.ShowPercent = True
dataLabels.Separator = ControlChars.Lf

' 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

The following code snippets (auto-collected from DevExpress Examples) contain references to the Separator 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/Charts.cs#L35

csharp
dataLabels.ShowPercent = true;
dataLabels.Separator = "\n";

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/CodeExamples/Charts.cs#L35

csharp
dataLabels.ShowPercent = true;
dataLabels.Separator = "\n";

spreadsheet-document-api-chart-examples/CS/SpreadsheetDocServerChartAPISamples/CodeExamples/ChartActions.cs#L47

csharp
dataLabels.ShowPercent = true;
dataLabels.Separator = "\n";

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/CodeExamples/Charts.vb#L39

vb
dataLabels.ShowPercent = True
dataLabels.Separator = vbLf

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/CodeExamples/Charts.vb#L38

vb
dataLabels.ShowPercent = True
dataLabels.Separator = Constants.vbLf

spreadsheet-document-api-chart-examples/VB/SpreadsheetDocServerChartAPISamples/CodeExamples/ChartActions.vb#L47

vb
dataLabels.ShowPercent = True
dataLabels.Separator = ControlChars.Lf

See Also

DataLabelBase Interface

DataLabelBase Members

DevExpress.Spreadsheet.Charts Namespace