Logarithmic Scale

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 System;
using CommunityToolkit.Mvvm.ComponentModel;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;

namespace ViewModelsSamples.Axes.Logarithmic;

[ObservableObject]
public partial class ViewModel
{
    // base 10 log, change the base if you require it.
    // or use any custom scale the logic is the same.
    private static readonly int s_logBase = 10;

    public ISeries[] Series { get; set; } =
    {
        new LineSeries<LogarithmicPoint>
        {
            Mapping = (logPoint, chartPoint) =>
            {
                // for the x coordinate, we use the X property of the LogaritmicPoint instance
                chartPoint.SecondaryValue = logPoint.X;

                // but for the Y coordinate, we will map to the logarithm of the value
                chartPoint.PrimaryValue = Math.Log(logPoint.Y, s_logBase); // mark
            },
            Values = new LogarithmicPoint[]
            {
                new() { X = 1, Y = 10 },
                new() { X = 2, Y = 100 },
                new() { X = 3, Y = 1000 },
                new() { X = 4, Y = 10000 },
                new() { X = 5, Y = 100000 },
                new() { X = 6, Y = 1000000 },
                new() { X = 7, Y = 10000000 }
            }
        }
    };

    public Axis[] YAxes { get; set; } =
    {
        new Axis
        {
            // forces the step of the axis to be at least 1
            MinStep = 1,

            // converts the log scale back for the label
            Labeler = value => Math.Pow(s_logBase, value).ToString() // mark
        }
    };
}

LogarithmicPoint.cs

namespace ViewModelsSamples.Axes.Logarithmic;

public class LogarithmicPoint
{
    public double X { get; set; }
    public double Y { get; set; }
}

XAML

<UserControl x:Class="WPFSample.Axes.Logarithmic.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.Logarithmic;assembly=ViewModelsSamples">
    <UserControl.DataContext>
        <vms:ViewModel/>
    </UserControl.DataContext>
    <lvc:CartesianChart
        Series="{Binding Series}"
        DrawMarginFrame="{Binding Frame}"
        XAxes="{Binding XAxes}"
        YAxes="{Binding YAxes}">
    </lvc:CartesianChart>
</UserControl>

Articles you might also find useful: