Skip to main content
All docs
V26.1
  • BarDataLabel.LabelPosition Property

    Gets or sets the position of this label relative to its bar.

    Namespace: DevExpress.Docs.Office

    Assembly: DevExpress.Docs.Core.v26.1.dll

    Declaration

    public BarDataLabelPosition LabelPosition { get; set; }

    Property Value

    Type Description
    BarDataLabelPosition

    A value that specifies where to display the label.

    Available values:

    Name Description
    Center

    Displays the label in the center of the bar.

    InsideBase

    Displays the label inside the bar at the base value.

    InsideEnd

    Displays the label inside the bar at the end value.

    OutsideEnd

    Displays the label outside the bar at the end value.

    Default

    Uses the default label position for the current chart type.

    Example

    The following code snippet adds two bar series to a presentation chart and customizes the corresponding view:

    DevExpress Presentation API - Bar Chart Example

    using DevExpress.Docs.Office;
    using DevExpress.Docs.Presentation;
    using System.Drawing;
    
    namespace PresentationApiSample;
    
    public class Program {
        public static async Task Main(string[] _) {
    
            // Create a presentation and add a blank slide.
            Presentation presentation = new Presentation();
            presentation.Slides.Clear();
            Slide slide = new Slide(SlideLayoutType.Blank);
            presentation.Slides.Add(slide);
    
            // Insert a chart that fills the slide.
            Chart chart = new Chart();
            chart.Width = presentation.SlideSize.Width;
            chart.Height = presentation.SlideSize.Height;
            slide.Shapes.Add(chart);
    
            // Set text properties common for all chart text elements.
            chart.TextProperties = new TextProperties { FontSize = 24, Bold = true };
    
            // Add the first bar series.
            BarSeries series1 = new BarSeries();
            series1.Arguments = new ChartStringData(new[] { "Q1", "Q2", "Q3" });
            series1.Values = new ChartNumericData(new double[] { 120, 95, 140 });
            chart.Series.Add(series1);
    
            // Configure data labels for the first series.
            series1.DataLabels.ShowValue = true;
            series1.DataLabels.LabelPosition = BarDataLabelPosition.OutsideEnd;
    
            // Add the second bar series.
            BarSeries series2 = new BarSeries();
            series2.Arguments = new ChartStringData(new[] { "Q1", "Q2", "Q3" });
            series2.Values = new ChartNumericData(new double[] { 80, 110, 100 });
            chart.Series.Add(series2);
    
            // Configure data labels for the second series.
            series2.DataLabels.ShowValue = true;
            series2.DataLabels.LabelPosition = BarDataLabelPosition.InsideEnd;
    
            // Access the bar chart view and customize its appearance.
            BarChartView view = (BarChartView)chart.Views[0];
            view.BarDirection = BarChartDirection.Bar;
            view.BarGrouping = BarChartGrouping.Clustered;
            view.GapWidth = 100;
            view.Overlap = -20;
    
            // Save the presentation to a file or export it.
            // ...
        }
    }
    
    See Also