Back to Devexpress

How to: Conditionally Hide Series Labels

windowsforms-4941-controls-and-libraries-chart-control-examples-creating-charts-appearance-customization-how-to-conditionally-hide-series-labels.md

latest2.0 KB
Original Source

How to: Conditionally Hide Series Labels

  • Nov 13, 2018

Handle the ChartControl.CustomDrawSeriesPoint event to conditionally hide series labels. In the event handler, change the CustomDrawSeriesPointEventArgs.LabelText property value to String.Empty to hide a label.

Note

Handling the WebChartControl.CustomDrawSeriesPoint (ChartControlSettings.CustomDrawSeriesPoint) event is necessary to perform the same for the Chart Control for ASP.NET and MVC.

csharp
private void OnCustomDrawSeriesPoint(object sender, CustomDrawSeriesPointEventArgs e) {
    if (e.SeriesPoint.Values[0] < 1) {
        e.LabelText = String.Empty;
    }
}
vb
Private Sub OnCustomDrawSeriesPoint(ByVal sender As Object, ByVal e As CustomDrawSeriesPointEventArgs) Handles chartControl1.CustomDrawSeriesPoint
    If e.SeriesPoint.Values(0) < 1 Then
        e.LabelText = String.Empty
    End If
End Sub

The following image demonstrates the result:

See Also

Series Point Labels

How to: Avoid Overlapping of Series Labels

How to: Make Series Labels Display Custom Information