Error Bars

The [ObservableObject], [ObservableProperty] and [ICommand] attributes come from the CommunityToolkit.Mvvm package, you can read 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 CommunityToolkit.Mvvm.ComponentModel;
using LiveChartsCore;
using LiveChartsCore.Defaults;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Painting;
using SkiaSharp;

namespace ViewModelsSamples.Error.Basic;

public partial class ViewModel : ObservableObject
{
    public ISeries[] Series { get; set; } =
    {
        // use the ErrorValue type to define the error in Y
        new ColumnSeries<ErrorValue>
        {
            Values = new ErrorValue[]
            {
                // (Y, Y+- error) // mark
                new(65, 6),
                // (Y, Y+ error, Y- error) // mark
                new(70, 15, 4),
                new(35, 4),
                new(70, 6),
                new(30, 5),
                new(60, 4, 16),
                new(65, 6)
            },
            ErrorPaint = new SolidColorPaint(SKColors.Black)
        },

        // When you need to define the error in X and Y use the ErrorPoint type // mark
        new ColumnSeries<ErrorPoint>
        {
            Values = new ErrorPoint[]
            {
                // (X, Y, Y+- error, Y+- error) // mark
                new(0, 50, 0.2, 8),
                // (X, Y, X- error, X+ erorr, Y+ error, Y- error) // mark
                new(1, 45, 0.1, 0.3, 15, 4),
                new(2, 25, 0.3, 4),
                new(3, 30, 0.2, 6),
                new(4, 70, 0.2, 8),
                new(5, 30, 0.4, 4),
                new(6, 50, 0.3, 6)
            },
            ErrorPaint = new SolidColorPaint(SKColors.Black)
        }

        // Error marks are also supported in LineSeries<T> and RowSeries<T> // mark
    };
}

XAML

<UserControl x:Class="UnoWinUISample.Error.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.Error.Basic"
            mc:Ignorable="d">
    <UserControl.DataContext>
        <vms:ViewModel/>
    </UserControl.DataContext>
    <lvc:CartesianChart
        Series="{Binding Series}">
    </lvc:CartesianChart>
</UserControl>

Articles you might also find useful:

Error bard in line series

In the previous sample you can replace the ColumnSeries<ErrorValue> with LineSeries<ErrorValue> to create a line chart with error bars:

sample image 2

In the previous image, the Fill, GeometryFill and GeometryStroke properties are null.