Back to Devexpress

CustomDrawSeriesEventArgsBase.LegendText Property

corelibraries-devexpress-dot-xtracharts-dot-customdrawserieseventargsbase-73859885.md

latest6.1 KB
Original Source

CustomDrawSeriesEventArgsBase.LegendText Property

Gets or sets the text of the legend item of the series or series point that is currently being painted.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public string LegendText { get; set; }
vb
Public Property LegendText As String

Property Value

TypeDescription
String

The text of the legend for the series currently being painted.

|

Remarks

If the LegendText property is set to Empty or null ( Nothing in Visual Basic), the corresponding legend item will be hidden.

Example

This example demonstrates how you can conditionally customize legend items in the ChartControl.CustomDrawSeriesPoint event handler.

csharp
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...

private void chartControl1_CustomDrawSeriesPoint(object sender, 
CustomDrawSeriesPointEventArgs e) {
    if (Convert.ToDouble(e.SeriesPoint.Values[0]) > 5) {
        e.LegendText = "exceeded";
        e.LegendTextColor = Color.Red;
    }
    else {
        e.LegendMarkerVisible = false;
        e.LegendTextVisible = false;
    }
}
vb
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...

Private Sub chartControl1_CustomDrawSeriesPoint(ByVal sender As Object, _ 
ByVal e As CustomDrawSeriesPointEventArgs) Handles chartControl1.CustomDrawSeriesPoint
    If Convert.ToDouble(e.SeriesPoint.Values(0)) > 5 Then
        e.LegendText = "exceeded"
        e.LegendTextColor = Color.Red
    Else
        e.LegendMarkerVisible = False
        e.LegendTextVisible = False
    End If
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the LegendText 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.

winforms-dashboard-custom-items/CS/TutorialsCustomItems/CustomItems/FunnelItemControlProvider.cs#L69

csharp
e.LabelText = e.SeriesPoint.Argument + " - " + formattedValue;
    e.LegendText = e.SeriesPoint.Argument;
}

bi-dashboard-non-visual-custom-export/CS/DashboardExporterApp/ExportControlProviders/FunnelItemExportControlProvider.cs#L67

csharp
e.LabelText = e.SeriesPoint.Argument + " - " + e.LabelText;
    e.LegendText = e.SeriesPoint.Argument;
}

winforms-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/Funnel/FunnelItemControlProvider.cs#L64

csharp
e.LabelText = e.SeriesPoint.Argument + " - " + formattedValue;
    e.LegendText = e.SeriesPoint.Argument;
}

winforms-dashboard-custom-items/VB/TutorialsCustomItems/CustomItems/FunnelItemControlProvider.vb#L69

vb
e.LabelText = e.SeriesPoint.Argument & " - " & formattedValue
    e.LegendText = e.SeriesPoint.Argument
End Sub

bi-dashboard-non-visual-custom-export/VB/DashboardExporterApp/ExportControlProviders/FunnelItemExportControlProvider.vb#L64

vb
e.LabelText = e.SeriesPoint.Argument & " - " & e.LabelText
    e.LegendText = e.SeriesPoint.Argument
End Sub

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/Funnel/FunnelItemControlProvider.vb#L70

vb
e.LabelText = e.SeriesPoint.Argument & " - " & formattedValue
    e.LegendText = e.SeriesPoint.Argument
End Sub

See Also

CustomDrawSeries

CustomDrawSeriesPoint

Legend Items

CustomDrawSeriesEventArgsBase Class

CustomDrawSeriesEventArgsBase Members

DevExpress.XtraCharts Namespace