Layered Bars
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.
View Model
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
namespace ViewModelsSamples.Bars.Layered;
public class ViewModel
{
public int[] Values1 { get; set; } =
[6, 3, 5, 7, 3, 4, 6, 3];
public int[] Values2 { get; set; } =
[2, 4, 8, 9, 5, 2, 4, 7];
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="MauiSample.Bars.Layered.View"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.Maui;assembly=LiveChartsCore.SkiaSharpView.Maui"
xmlns:vms="clr-namespace:ViewModelsSamples.Bars.Layered;assembly=ViewModelsSamples"
x:DataType="vms:ViewModel">
<ContentPage.BindingContext>
<vms:ViewModel/>
</ContentPage.BindingContext>
<!--
When the bar positon is ignored, all bars are drawn in the same position.
-->
<lvc:CartesianChart>
<lvc:CartesianChart.Series>
<lvc:SeriesCollection>
<lvc:XamlColumnSeries
Values="{Binding Values1}"
MaxBarWidth="999999"
IgnoresBarPosition="True"/>
<lvc:XamlColumnSeries
Values="{Binding Values2}"
MaxBarWidth="30"
IgnoresBarPosition="True"/>
</lvc:SeriesCollection>
</lvc:CartesianChart.Series>
</lvc:CartesianChart>
</ContentPage>