Polar Coordinates
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.
View model
using System;
using LiveChartsCore.Defaults;
namespace ViewModelsSamples.Polar.Coordinates;
public class ViewModel
{
public ObservablePolarPoint[] Values { get;set; } = [
new(0, 10),
new(45, 15),
new(90, 20),
new(135, 25),
new(180, 30),
new(225, 35),
new(270, 40),
new(315, 45),
new(360, 50)
];
public Func<double, string> Labeler { get; set; } =
angle => $"{angle}°";
}
XAML
<UserControl
x:Class="WPFSample.Polar.Coordinates.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.Polar.Coordinates;assembly=ViewModelsSamples">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:PolarChart>
<lvc:PolarChart.Series>
<lvc:SeriesCollection>
<lvc:XamlPolarLineSeries
Values="{Binding Values}"
IsClosed="True"
Fill="{x:Null}"/>
</lvc:SeriesCollection>
</lvc:PolarChart.Series>
<lvc:PolarChart.AngleAxes>
<lvc:PolarAxesCollection>
<lvc:XamlPolarAxis
MinLimit="0"
MaxLimit="360"
Labeler="{Binding Labeler}"
ForceStepToMin="True"
MinStep="30"/>
</lvc:PolarAxesCollection>
</lvc:PolarChart.AngleAxes>
</lvc:PolarChart>
</UserControl>