Back to Devexpress

SeriesBase.LabelsVisibility Property

corelibraries-devexpress-dot-xtracharts-dot-seriesbase-81fb5d8c.md

latest11.1 KB
Original Source

SeriesBase.LabelsVisibility Property

Specifies whether to show labels for a series.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[XtraChartsLocalizableCategory(XtraChartsCategory.Appearance)]
public DefaultBoolean LabelsVisibility { get; set; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Appearance)>
Public Property LabelsVisibility As DefaultBoolean

Property Value

TypeDescription
DefaultBoolean

True to show series labels; False to hide them; Default - label visibility depends on the series view and chart control type.

|

Available values:

NameDescriptionReturn Value
True

The value is true.

|

0

| | False |

The value is false.

|

1

| | Default |

The value is specified by a global option or a higher-level object.

|

2

|

Remarks

Series point labels are visible in the following cases:

In all other cases, series labels are hidden until you enable them.

The following table shows the LabelsVisibility property in action.

LabelsVisibility = DefaultBoolean.FalseLabelsVisibility = DefaultBoolean.True

Example

This example demonstrates how to customize the Side-by-Side Bar series label position and appearance.

Use the following API members to customize bar series labels:

MemberDescription
Series.LabelsVisibilitySpecifies whether to show series labels.
BarSeriesLabelDefines label settings for bar series.
SeriesLabelBase.BackColorGets or sets the label’s background color.
SeriesLabelBase.BorderGets the label’s border settings.
SeriesLabelBase.FontGets or sets the font used to display the label’s content.
BarSeriesLabel.PositionSpecifies the position of series point labels, relative to their corresponding Bars.
SeriesLabelBase.TextOrientationSpecifies the direction of text within the series labels.
SeriesLabelBase.TextPatternGets or sets a string which represents the pattern specifying the text to be displayed within series labels.
csharp
private void OnFormLoad(object sender, EventArgs e) {
    chartControl1.Series[0].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;

    BarSeriesLabel seriesLabel = chartControl1.Series[0].Label as BarSeriesLabel;
    seriesLabel.BackColor = Color.White;
    seriesLabel.Border.Color = Color.DarkSlateGray;
    seriesLabel.Font = new Font("Tahoma", 10, FontStyle.Regular);
    seriesLabel.Position = BarSeriesLabelPosition.TopInside;
    seriesLabel.TextOrientation = TextOrientation.Horizontal;
    seriesLabel.TextPattern = "{V:F1}";            
}
vb
Private Sub OnFormLoad(ByVal sender As Object, ByVal e As EventArgs)
    chartControl1.Series(0).LabelsVisibility = DevExpress.Utils.DefaultBoolean.[True]

    Dim seriesLabel As BarSeriesLabel = TryCast(chartControl1.Series(0).Label, BarSeriesLabel)
    seriesLabel.BackColor = Color.White
    seriesLabel.Border.Color = Color.DarkSlateGray
    seriesLabel.Font = New Font("Tahoma", 10, FontStyle.Regular)
    seriesLabel.Position = BarSeriesLabelPosition.TopInside
    seriesLabel.TextOrientation = TextOrientation.Horizontal
    seriesLabel.TextPattern = "{V:F1}"
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the LabelsVisibility 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-charts-create-model-for-custom-chart-element/CS/CustomChartElementModel/Form1.cs#L119

csharp
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
series.Label.ResolveOverlappingMode = ResolveOverlappingMode.HideOverlapped;

winforms-charts-configure-settings-for-template-series-and-series-added-manually/CS/series-base-example/Form1.cs#L39

csharp
series.ValueScaleType= ScaleType.Numerical;
series.LabelsVisibility = DefaultBoolean.True;
series.Label.TextPattern = "{A}: {V:F2}";

winforms-charts-apply-the-best-fit-function-to-a-series/CS/LineOfBestFit/Form1.cs#L77

csharp
BestFit.ArgumentScaleType = ScaleType.Numerical;
BestFit.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
BestFit.Tag = tag;

winforms-charts-create-stacked-bar-chart/CS/Series_StackedBarChart/Form1.cs#L25

csharp
// Enable series point labels, specify their text pattern and position:
chart.SeriesTemplate.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
chart.SeriesTemplate.Label.TextPattern = "${V}M";

winforms-charts-create-a-side-by-side-stacked-bars/CS/SideBySideStackedBarChart/Form1.cs#L34

csharp
//Enable point labels and format their text.
chart.SeriesTemplate.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
chart.SeriesTemplate.Label.TextPattern = "{V}";

winforms-charts-create-model-for-custom-chart-element/VB/CustomChartElementModel/Form1.vb#L179

vb
view.Colorizer = New CustomPointColorizer() With {.Value = 60, .LowerValuePointColor = Color.Red, .UpperValuePointColor = Color.Green}
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True
series.Label.ResolveOverlappingMode = ResolveOverlappingMode.HideOverlapped

winforms-charts-configure-settings-for-template-series-and-series-added-manually/VB/series-base-example/Form1.vb#L39

vb
series.ValueScaleType = ScaleType.Numerical
series.LabelsVisibility = DefaultBoolean.True
series.Label.TextPattern = "{A}: {V:F2}"

winforms-charts-apply-the-best-fit-function-to-a-series/VB/LineOfBestFit/Form1.vb#L85

vb
BestFit.ArgumentScaleType = ScaleType.Numerical
BestFit.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False
BestFit.Tag = tag

winforms-charts-create-stacked-bar-chart/VB/Series_StackedBarChart/Form1.vb#L26

vb
' Enable series point labels, specify their text pattern and position:
chart.SeriesTemplate.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True
chart.SeriesTemplate.Label.TextPattern = "${V}M"

winforms-charts-create-a-side-by-side-stacked-bars/VB/SideBySideStackedBarChart/Form1.vb#L35

vb
'Enable point labels and format their text.
chart.SeriesTemplate.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True
chart.SeriesTemplate.Label.TextPattern = "{V}"

See Also

SeriesBase Class

SeriesBase Members

DevExpress.XtraCharts Namespace