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 ContentPage 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

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="MauiSample.Box.Basic.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.Box.Basic;assembly=ViewModelsSamples"
    x:DataType="vms:ViewModel">

    <ContentPage.BindingContext>
        <vms:ViewModel/>
    </ContentPage.BindingContext>

    <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="#c8c8c8"
                    SeparatorsAtCenter="False"
                    TicksPaint="#232323"
                    TicksAtCenter="True"/>
            </lvc:AxesCollection>
        </lvc:CartesianChart.XAxes>
        
    </lvc:CartesianChart>
</ContentPage>

Articles you might also find useful: