Grouped And Stacked Bars
This sample uses C# 12 features, it also uses features from the CommunityToolkit.Mvvm package, you can learn more about it here.
This web site wraps every sample using a ContentPage
instance, but LiveCharts controls can be used inside any container.

View model
using LiveChartsCore;
using LiveChartsCore.Kernel.Sketches;
using LiveChartsCore.SkiaSharpView;
namespace ViewModelsSamples.StackedBars.Groups;
public class ViewModel
{
public ISeries[] Series { get; set; } =
[
new StackedColumnSeries<int>
{
Values = [3, 5, 3],
Stroke = null,
StackGroup = 0 // mark
},
new StackedColumnSeries<int>
{
Values = [4, 2, 3],
Stroke = null,
StackGroup = 0 // mark
},
new StackedColumnSeries<int>
{
Values = [4, 6, 6],
Stroke = null,
StackGroup = 1 // mark
},
new StackedColumnSeries<int>
{
Values = [2, 5, 4],
Stroke = null,
StackGroup = 1 // mark
}
];
public ICartesianAxis[] XAxis { get; set; } = [
new Axis
{
LabelsRotation = -15,
Labels = ["Category 1", "Category 2", "Category 3"]
}
];
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="MauiSample.StackedBars.Groups.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.StackedBars.Groups;assembly=ViewModelsSamples">
<ContentPage.BindingContext>
<vms:ViewModel/>
</ContentPage.BindingContext>
<lvc:CartesianChart Series="{Binding Series}" XAxes="{Binding XAxis}" />
</ContentPage>