Skip to main content

Data labels

info

Charts are available with Avalonia Pro.

Data labels place the actual values directly on the chart series. This lets readers compare values without estimating them from axis positions.

Bar chart with data labels displayed above each quarterly revenue bar.

When to use

  • Presentation graphics: Where clear, immediate values are prioritized.
  • Small multiples: When axes are omitted to save space.
  • Key milestones: Highlighting specific values that require attention.

Code example

XAML

<charts:CartesianChart Name="BasicLabelsChart" Height="250">
<charts:CartesianChart.Series>
<charts:BarSeries Title="Sales" ItemsSource="{Binding SalesData}"
CategoryPath="Category" ValuePath="Value"
ShowLabels="True" LabelOffset="5"/>
</charts:CartesianChart.Series>
<charts:CartesianChart.HorizontalAxis>
<charts:CategoryAxis Title="Quarter" />
</charts:CartesianChart.HorizontalAxis>
<charts:CartesianChart.VerticalAxis>
<charts:NumericalAxis Title="Revenue" />
</charts:CartesianChart.VerticalAxis>
</charts:CartesianChart>

Data model (C#)

public record SalesPoint(string Category, double Value);

public ObservableCollection<SalesPoint> SalesData { get; } = new()
{
new("Q1", 120),
new("Q2", 150),
new("Q3", 180),
new("Q4", 220)
};

Common properties (on Series)

PropertyDescriptionDefault
ShowLabelsToggles values on the series points.false
LabelFormatString format. {0} is the value and {1} is the category."{0:N0}"
LabelFontSizeSize of the text in pixels.12.0
LabelForegroundBrush used for the text color.null
LabelBackgroundBrush used behind the label text.null
LabelCornerRadiusCorner radius for the label background.4
LabelPaddingPadding inside the label background.4,2
LabelOffsetDistance from the data point to the label.10.0