Pushout

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.Pies.Pushout;

public class PieData(string name, double value, double pushout)
{
    public string Name { get; set; } = name;
    public double[] Values { get; set; } = [value];
    public double Pushout { get; set; } = pushout;
}

public class ViewModel
{
    public PieData[] Data { get; set; } = [
        new("Maria",    8, 30),
        new("Susan",    6, 0),
        new("Charles",  5, 0),
        new("Fiona",    3, 0),
        new("George",   3, 0)
    ];
}

XAML

<UserControl
    x:Class="WinUISample.Pies.Pushout.View"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:lvc="using:LiveChartsCore.SkiaSharpView.WinUI"
    xmlns:vms="using:ViewModelsSamples.Pies.Pushout"
    mc:Ignorable="d">

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

    <lvc:PieChart SeriesSource="{Binding Data}">
        <lvc:PieChart.SeriesTemplate>
            <DataTemplate>
                <lvc:XamlPieSeries
                    SeriesName="{Binding Name}"
                    Values="{Binding Values}"
                    Pushout="{Binding Pushout}"/>
            </DataTemplate>
        </lvc:PieChart.SeriesTemplate>
    </lvc:PieChart>

</UserControl>

Articles you might also find useful: