Axis Style
Notice this web site wraps every sample using the UserControl
class, but LiveCharts controls can be used inside any container,
this sample also follows a Model-View-* pattern.

View model
using System.Collections.Generic;
using LiveChartsCore;
using LiveChartsCore.Kernel.Sketches;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Painting;
using LiveChartsCore.SkiaSharpView.Painting.Effects;
using SkiaSharp;
namespace ViewModelsSamples.Axes.Style;
public class ViewModel
{
public IEnumerable<ISeries> Series { get; set; }
= new ISeries[] {
new LineSeries<int>
{
Values = new int[] { 5, 3, 2, 8, 7, 4, 5, 4, 6, 7, 5 },
Fill = null,
GeometrySize = 0
}
};
public IEnumerable<Axis> XAxes { get; set; }
= new Axis[]
{
new Axis
{
MinLimit = 0,
MaxLimit = 10,
ForceStepToMin = true,
MinStep = 0.5,
TextSize = 14,
SeparatorsPaint = new SolidColorPaint
{
Color = SKColors.Gray,
StrokeThickness = 2
}
}
};
public IEnumerable<ICartesianAxis> YAxes { get; set; }
= new Axis[]
{
new Axis
{
MinLimit = 0,
MaxLimit = 10,
ForceStepToMin = true,
MinStep = 1,
TextSize = 14,
SeparatorsPaint = new SolidColorPaint
{
Color = SKColors.Gray,
StrokeThickness = 2,
PathEffect = new DashEffect(new float[] { 3, 3 })
}
}
};
public DrawMarginFrame Frame { get; set; }
= new DrawMarginFrame
{
Fill = new SolidColorPaint
{
Color = new SKColor(0, 0, 0, 30)
},
Stroke = new SolidColorPaint
{
Color = new SKColor(80, 80, 80),
StrokeThickness = 2
}
};
}
XAML
<UserControl x:Class="WPFSample.Axes.Style.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.Style;assembly=ViewModelsSamples">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}">
</lvc:CartesianChart>
</UserControl>