Column Width

This sample uses C# 13 preview features such as partial properties, it also uses features from the CommunityToolkit.Mvvm package, you can learn more about it here.

This web site wraps every sample using a UserControl instance, but LiveCharts controls can be used inside any container.

sample image

View model

namespace ViewModelsSamples.Bars.Spacing;

public class ViewModel
{
    public double[] Values { get; set; } =
        [20, 50, 40, 20, 40, 30, 50, 20, 50, 40];
}

XAML

<UserControl
    x:Class="AvaloniaSample.Bars.Spacing.View"
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"
    xmlns:vms="using:ViewModelsSamples.Bars.Spacing"
    x:DataType="vms:ViewModel">

  <UserControl.DataContext>
    <vms:ViewModel/>
  </UserControl.DataContext>

  <!--
  Padding: Defines the distance between every bars in the series
  MaxBarWidth: Defines the maximum width a bar can take
  -->

  <lvc:CartesianChart>
    <lvc:CartesianChart.Series>
      <lvc:XamlColumnSeries
          Values="{Binding Values}"
          Padding="0"
          MaxBarWidth="99999"/>
    </lvc:CartesianChart.Series>
  </lvc:CartesianChart>

</UserControl>

Articles you might also find useful: