Skip to main content

Bar chart

info

Charts are available with Avalonia Pro.

Bar charts represent data using rectangular bars with lengths proportional to the values they represent.

Bar chart with vertical rectangular bars of varying heights comparing quarterly revenue across categories.

When to use

  • Comparisons: Comparing discrete quantities across different categories.
  • Ranking: Showing which categories have the highest or lowest values.
  • Categorical data: When data is grouped into distinct, non-continuous groups.

Code example

XAML

<charts:CartesianChart Name="BarChart" Title="Bar Chart" Height="250">
<charts:CartesianChart.HorizontalAxis>
<charts:CategoryAxis />
</charts:CartesianChart.HorizontalAxis>
<charts:CartesianChart.VerticalAxis>
<charts:NumericalAxis />
</charts:CartesianChart.VerticalAxis>
<charts:CartesianChart.Series>
<charts:BarSeries Title="Sales" ItemsSource="{Binding BarSeriesData}" Fill="DodgerBlue" />
</charts:CartesianChart.Series>
</charts:CartesianChart>

Data model (C#)

public ObservableCollection<int> BarSeriesData { get; } = new()
{
150, 180, 165, 190, 175, 200
};

Common properties

PropertyDescriptionDefault
TitleThe name of the series shown in the legend.null
ItemsSourceThe collection of data items to display.null
CategoryPathPath to the property used for the X-axis.null
ValuePathPath to the property used for the Y-axis.null
FillThe color/brush used to fill the bars.Theme-dependent
StrokeThe outline color of the bars.Transparent
ColorByPointWhether each bar uses its own palette color.false
BarCornerRadiusThe rounding of the bar corners.0
BarWidthThe width of each bar as a fraction of the category band (0.0 to 1.0).0.7