Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DataLabelCollection.SetVisibility(Int32, Boolean) Method

Shows or hides a data label for the specified data point.

Namespace: DevExpress.Spreadsheet.Charts

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

NuGet Package: DevExpress.Spreadsheet.Core

#Declaration

void SetVisibility(
    int itemIndex,
    bool visible
)

#Parameters

Name Type Description
itemIndex Int32

The zero-based position of the target data point within the series.

visible Boolean

true to display the label for the data point; otherwise, false.

#Remarks

Use the DataLabelCollection.IsVisible method to determine whether a data label for a specific data point is displayed. The DataLabelCollection.HiddenLabels property returns the hidden label collection.

#Show Individual Data Labels

The example below displays data labels for the minimum and maximum data points on the chart.

Specify data label visibility for the column chart

// 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"];

// Hide the chart's legend.
chart.Legend.Visible = false;

chart.Series[0].UseCustomDataLabels = true;
// Display the label for the third data point (minimum value).
chart.Series[0].CustomDataLabels.SetVisibility(2, true);
// Display the label for the sixth data point (maximum value).
chart.Series[0].CustomDataLabels.SetVisibility(5, true);

#Hide Individual Data Labels

The example below displays data labels for all data points on the chart except for the first point.

Hide a data label on the column chart

// 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"];

// Hide the chart's legend.
chart.Legend.Visible = false;

chart.Series[0].UseCustomDataLabels = true;
// Display data point values.
chart.Series[0].CustomDataLabels.ShowValue = true;
// Hide the first data label.
chart.Series[0].CustomDataLabels.SetVisibility(0, false);
// You can also use the Hidden property to hide the label.
//chart.Series[0].CustomDataLabels.Add(0).Hidden = true;
See Also