Back to Devexpress

CustomDrawSeriesPointEventArgs.LabelText Property

corelibraries-devexpress-dot-xtracharts-dot-customdrawseriespointeventargs-61bb64bd.md

latest7.5 KB
Original Source

CustomDrawSeriesPointEventArgs.LabelText Property

Gets or sets the text of a label for the point currently being painted.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

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

Property Value

TypeDescription
String

A String representing a label’s text.

|

Remarks

Use the LabelText property to change the text of a label for the point currently being painted when handling the ChartControl.CustomDrawSeriesPoint event. For a series with points containing two labels, you can also specify the CustomDrawSeriesPointEventArgs.SecondLabelText property.

Note

If the LabelText property is set to Empty or null ( Nothing in Visual Basic), this label will be hidden.

Example

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 code snippets (auto-collected from DevExpress Examples) contain references to the LabelText 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#L68

csharp
string formattedValue = flatData.GetDisplayText(dashboardItem.Metadata.Value.UniqueId, row);
e.LabelText = e.SeriesPoint.Argument + " - " + formattedValue;
e.LegendText = e.SeriesPoint.Argument;

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

csharp
void CustomDrawSeriesPoint(object sender, CustomDrawSeriesPointEventArgs e) {
    e.LabelText = e.SeriesPoint.Argument + " - " + e.LabelText;
    e.LegendText = e.SeriesPoint.Argument;

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

csharp
string formattedValue = flatData.GetDisplayText(dashboardItem.Metadata.Value.UniqueId, row);
e.LabelText = e.SeriesPoint.Argument + " - " + formattedValue;
e.LegendText = e.SeriesPoint.Argument;

winforms-chart-conditionally-hide-series-labels/CS/Form1.cs#L30

csharp
if(!e.Series.Points.Max(p => p.ArgumentX.NumericalArgument).Equals(e.SeriesPoint.NumericalArgument)) {
    e.LabelText = "";
}

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

vb
Dim formattedValue As String = flatData.GetDisplayText(dashboardItem.Metadata.Value.UniqueId, row)
e.LabelText = e.SeriesPoint.Argument & " - " & formattedValue
e.LegendText = e.SeriesPoint.Argument

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

vb
Private Sub CustomDrawSeriesPoint(ByVal sender As Object, ByVal e As CustomDrawSeriesPointEventArgs)
    e.LabelText = e.SeriesPoint.Argument & " - " & e.LabelText
    e.LegendText = e.SeriesPoint.Argument

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

vb
Dim formattedValue As String = flatData.GetDisplayText(dashboardItem.Metadata.Value.UniqueId, row)
e.LabelText = e.SeriesPoint.Argument & " - " & formattedValue
e.LegendText = e.SeriesPoint.Argument

winforms-chart-conditionally-hide-series-labels/VB/Form1.vb#L28

vb
If Not Enumerable.Max(e.Series.Points, Function(p) p.ArgumentX.NumericalArgument).Equals(e.SeriesPoint.NumericalArgument) Then
    e.LabelText = ""
End If

See Also

SecondLabelText

CustomDrawSeriesPointEventArgs Class

CustomDrawSeriesPointEventArgs Members

DevExpress.XtraCharts Namespace