Angular Gauge
This sample uses C# 12 features, it also uses features from the CommunityToolkit.Mvvm package, you can learn more about it here.

View model
using System.Collections.Generic;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Extensions;
using LiveChartsCore.VisualElements;
using LiveChartsCore.SkiaSharpView.VisualElements;
using LiveChartsCore.Defaults;
using CommunityToolkit.Mvvm.Input;
using System;
namespace ViewModelsSamples.Pies.AngularGauge;
public partial class ViewModel
{
private readonly Random _random = new();
public IEnumerable<ISeries> Series { get; set; }
public IEnumerable<VisualElement> VisualElements { get; set; }
public NeedleVisual Needle { get; set; }
public ViewModel()
{
var sectionsOuter = 130;
var sectionsWidth = 20;
Needle = new NeedleVisual
{
Value = 45
};
Series = GaugeGenerator.BuildAngularGaugeSections(
new GaugeItem(60, s => SetStyle(sectionsOuter, sectionsWidth, s)),
new GaugeItem(30, s => SetStyle(sectionsOuter, sectionsWidth, s)),
new GaugeItem(10, s => SetStyle(sectionsOuter, sectionsWidth, s)));
VisualElements =
[
new AngularTicksVisual
{
Labeler = value => value.ToString("N1"),
LabelsSize = 16,
LabelsOuterOffset = 15,
OuterOffset = 65,
TicksLength = 20
},
Needle
];
}
[RelayCommand]
public void DoRandomChange()
{
// modifying the Value property updates and animates the chart automatically
Needle.Value = _random.Next(0, 100);
}
private static void SetStyle(
double sectionsOuter, double sectionsWidth, PieSeries<ObservableValue> series)
{
series.OuterRadiusOffset = sectionsOuter;
series.MaxRadialColumnWidth = sectionsWidth;
series.CornerRadius = 0;
}
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="MauiSample.Pies.AngularGauge.View"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.Maui;assembly=LiveChartsCore.SkiaSharpView.Maui"
xmlns:vms="clr-namespace:ViewModelsSamples.Pies.AngularGauge;assembly=ViewModelsSamples">
<ContentPage.BindingContext>
<vms:ViewModel/>
</ContentPage.BindingContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Command="{Binding DoRandomChangeCommand}">Change Value</Button>
<lvc:PieChart
Grid.Row="1"
Series="{Binding Series}"
VisualElements="{Binding VisualElements}"
InitialRotation="-225"
MaxAngle="270"
MinValue="0"
MaxValue="100">
</lvc:PieChart>
</Grid>
</ContentPage>