Box Series

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

using LiveChartsCore.Defaults;

namespace ViewModelsSamples.Box.Basic;

public class ViewModel
{
    public BoxValue[] Values1 { get; set; } =
        [
            // max, upper quartile, median, lower quartile, min
            new(100, 80, 60, 20, 70),
            new(90, 70, 50, 30, 60),
            new(80, 60, 40, 10, 50)
        ];

    public BoxValue[] Values2 { get; set; } =
        [
            new(90, 70, 50, 30, 60),
            new(80, 60, 40, 10, 50),
            new(70, 50, 30, 20, 40)
        ];

    public BoxValue[] Values3 { get; set; } =
        [
            new(80, 60, 40, 10, 50),
            new(70, 50, 30, 20, 40),
            new(60, 40, 20, 10, 30)
        ];

    public string[] Labels { get; set; } =
        ["Apperitizers", "Mains", "Desserts"];
}

XAML

<UserControl x:Class="WinUISample.Box.Basic.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.Box.Basic"
            mc:Ignorable="d">

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

    <lvc:CartesianChart LegendPosition="Right">

        <lvc:CartesianChart.Series>
            <lvc:SeriesCollection>
                <lvc:XamlBoxSeries
                    SeriesName="Year 2023"
                    Values="{Binding Values1}"/>
                <lvc:XamlBoxSeries
                    SeriesName="Year 2024"
                    Values="{Binding Values2}"/>
                <lvc:XamlBoxSeries
                    SeriesName="Year 2025"
                    Values="{Binding Values3}"/>
            </lvc:SeriesCollection>
        </lvc:CartesianChart.Series>

        <lvc:CartesianChart.XAxes>
            <lvc:AxesCollection>
                <lvc:XamlAxis
                    Labels="{Binding Labels}"
                    LabelsRotation="0"
                    SeparatorsPaint="{lvc:SolidColorPaint Color='#c8c8c8'}"
                    SeparatorsAtCenter="False"
                    TicksPaint="{lvc:SolidColorPaint Color='#232323'}"
                    TicksAtCenter="True"/>
            </lvc:AxesCollection>
        </lvc:CartesianChart.XAxes>
        
    </lvc:CartesianChart>
</UserControl>

Articles you might also find useful: