Basic
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 LiveChartsCore;
namespace ViewModelsSamples.Polar.Basic;
public class ViewModel
{
public double[] Values { get; set; } =
[15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
public double CotangentAngle { get; set; } =
LiveCharts.CotangentAngle;
public double TangentAngle { get; set; } =
LiveCharts.TangentAngle;
}
XAML
<UserControl
x:Class="AvaloniaSample.Polar.Basic.View"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"
xmlns:vms="using:ViewModelsSamples.Polar.Basic"
xmlns:c="using:LiveChartsCore"
x:DataType="vms:ViewModel">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:PolarChart>
<lvc:PolarChart.Title>
<lvc:XamlDrawnLabelVisual
Text="My chart title"
Paint="{lvc:SolidColorPaint Color='#303030'}"
TextSize="25"
Padding="{lvc:Padding '15'}"/>
</lvc:PolarChart.Title>
<lvc:PolarChart.Series>
<lvc:XamlPolarLineSeries
Values="{Binding Values}"
ShowDataLabels="True"
GeometrySize="15"
DataLabelsSize="8"
DataLabelsPosition="Middle"
DataLabelsRotation="{x:Static c:LiveCharts.CotangentAngle}"
IsClosed="True"/>
</lvc:PolarChart.Series>
<lvc:PolarChart.RadiusAxes>
<lvc:XamlPolarAxis
LabelsAngle="-60"
MaxLimit="30"/>
</lvc:PolarChart.RadiusAxes>
<lvc:PolarChart.AngleAxes>
<lvc:XamlPolarAxis
LabelsRotation="{x:Static c:LiveCharts.TangentAngle}"/>
</lvc:PolarChart.AngleAxes>
</lvc:PolarChart>
</UserControl>