Gruped And Stacked Bars
Notice this web site wraps every sample using the ContentPage
class, but LiveCharts controls can be used inside any container,
this sample also follows a Model-View-* pattern.

View model
using System.Collections.Generic;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
namespace ViewModelsSamples.StackedBars.Groups;
public class ViewModel
{
public ISeries[] Series { get; set; }
= {
new StackedColumnSeries<int>
{
Values = new List<int> { 3, 5, 3 },
Stroke = null,
MaxBarWidth = 80,
GroupPadding = 60,
StackGroup = 0 // mark
},
new StackedColumnSeries<int>
{
Values = new List<int> { 4, 2, 3 },
Stroke = null,
MaxBarWidth = 80,
GroupPadding = 60,
StackGroup = 0 // mark
},
new StackedColumnSeries<int>
{
Values = new List<int> { 4, 6, 6 },
Stroke = null,
MaxBarWidth = 80,
GroupPadding = 60,
StackGroup = 1 // mark
},
new StackedColumnSeries<int>
{
Values = new List<int> { 2, 5, 4 },
Stroke = null,
MaxBarWidth = 80,
GroupPadding = 60,
StackGroup = 1 // mark
}
};
public Axis[] XAxis { get; set; }
= {
new Axis
{
LabelsRotation = -15,
Labels = new[] { "Category 1", "Category 2", "Category 3" }
}
};
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamarinSample.StackedBars.Groups.View"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.Xamarin.Forms;assembly=LiveChartsCore.SkiaSharpView.XamarinForms"
xmlns:vms="clr-namespace:ViewModelsSamples.StackedBars.Groups;assembly=ViewModelsSamples">
<ContentPage.BindingContext>
<vms:ViewModel/>
</ContentPage.BindingContext>
<lvc:CartesianChart Series="{Binding Series}" XAxes="{Binding XAxis}"/>
</ContentPage>