Back to Devexpress

BarSeriesLabel.Position Property

corelibraries-devexpress-dot-xtracharts-dot-barserieslabel-91824159.md

latest8.0 KB
Original Source

BarSeriesLabel.Position Property

Specifies the position of series point labels, relative to their corresponding Bars.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public BarSeriesLabelPosition Position { get; set; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property Position As BarSeriesLabelPosition

Property Value

TypeDescription
BarSeriesLabelPosition

A BarSeriesLabelPosition enumeration value that specifies the label position.

|

Available values:

NameDescription
Auto

Enables the algorithm which calculates the label position inside bars with respect to chart size.

| | Top |

Labels are displayed above Bars.

| | Center |

Labels are displayed in the center of Bars.

| | TopInside |

Labels are displayed inside Bars, at the top.

| | BottomInside |

Labels are displayed inside Bars, at the bottom.

|

Remarks

When the Position property is set to Top , the lines that connect labels with their corresponding points become visible, and the following properties become available: SeriesLabelBase.LineColor, SeriesLabelBase.LineLength, SeriesLabelBase.LineStyle and SeriesLabelBase.LineVisibility.

When the Position property is set to TopInside or BottomInside , the BarSeriesLabel.Indent property specifies an indent between a label and the corresponding side of a Bar.

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 snippet (auto-collected from DevExpress Examples) contains a reference to the Position 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-stacked-bar-chart/CS/Series_StackedBarChart/Form1.cs#L27

csharp
chart.SeriesTemplate.Label.TextPattern = "${V}M";
((BarSeriesLabel)chart.SeriesTemplate.Label).Position = BarSeriesLabelPosition.Center;

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

vb
chart.SeriesTemplate.Label.TextPattern = "${V}M"
CType(chart.SeriesTemplate.Label, BarSeriesLabel).Position = BarSeriesLabelPosition.Center
' Customize series view settings (for example, bar width):

See Also

Indent

TextOrientation

BarSeriesLabel Class

BarSeriesLabel Members

DevExpress.XtraCharts Namespace