Custom Separators Interval

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.Axes.CustomSeparatorsInterval;

public class ViewModel
{
    public int[] Values { get; set; } =
        [10, 55, 45, 68, 60, 70, 75, 78];

    public double[] CustomSeparators { get; set; } =
        [0, 10, 25, 50, 100];
}

XAML

<UserControl
    x:Class="WPFSample.Axes.CustomSeparatorsInterval.View"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
    xmlns:vms="clr-namespace:ViewModelsSamples.Axes.CustomSeparatorsInterval;assembly=ViewModelsSamples">

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

    <lvc:CartesianChart>

        <lvc:CartesianChart.Series>
            <lvc:SeriesCollection>
                <lvc:XamlLineSeries Values="{Binding Values}"/>
            </lvc:SeriesCollection>
        </lvc:CartesianChart.Series>

        <lvc:CartesianChart.YAxes>
            <lvc:AxesCollection>
                <lvc:XamlAxis
                    CustomSeparators="{Binding CustomSeparators}"
                    MinLimit="0"
                    MaxLimit="100"
                    SeparatorsPaint="#64b4b4b4"/>
            </lvc:AxesCollection>
        </lvc:CartesianChart.YAxes>

    </lvc:CartesianChart>

</UserControl>

Articles you might also find useful: