Radial Area
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 ContentPage
instance, but LiveCharts controls can be used inside any container.
View model
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Painting;
using SkiaSharp;
using CommunityToolkit.Mvvm.ComponentModel;
namespace ViewModelsSamples.Polar.RadialArea;
public partial class ViewModel : ObservableObject
{
public ISeries[] Series { get; set; } =
{
new PolarLineSeries<int>
{
Values = new[] { 7, 5, 7, 5, 6 },
LineSmoothness = 0,
GeometrySize= 0,
Fill = new SolidColorPaint(SKColors.Blue.WithAlpha(90))
},
new PolarLineSeries<int>
{
Values = new[] { 2, 7, 5, 9, 7 },
LineSmoothness = 1,
GeometrySize = 0,
Fill = new SolidColorPaint(SKColors.Red.WithAlpha(90))
}
};
public PolarAxis[] AngleAxes { get; set; } =
{
new PolarAxis
{
LabelsRotation = LiveCharts.TangentAngle,
Labels = new[] { "first", "second", "third", "forth", "fifth" }
}
};
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamarinSample.Polar.RadialArea.View"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.Xamarin.Forms;assembly=LiveChartsCore.SkiaSharpView.XamarinForms"
xmlns:vms="clr-namespace:ViewModelsSamples.Polar.RadialArea;assembly=ViewModelsSamples">
<ContentPage.BindingContext>
<vms:ViewModel/>
</ContentPage.BindingContext>
<lvc:PolarChart Series="{Binding Series}" AngleAxes="{Binding AngleAxes}" InitialRotation="-45" />
</ContentPage>