Skip to main content
A newer version of this page is available. .
All docs
V23.1
.NET Framework 4.5.2+

DataLabelCollection.SetVisibility(Int32, Boolean) Method

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

Namespace: DevExpress.Spreadsheet.Charts

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

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