Auto Updates On Gauges
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 System;
using System.Collections.Generic;
using LiveChartsCore;
using LiveChartsCore.Defaults;
using LiveChartsCore.Measure;
using LiveChartsCore.SkiaSharpView;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace ViewModelsSamples.Pies.Gauge5;
public partial class ViewModel : ObservableObject
{
private readonly Random _random = new();
public ViewModel()
{
ObservableValue1 = new ObservableValue { Value = 50 };
ObservableValue2 = new ObservableValue { Value = 80 };
Series = new GaugeBuilder()
.WithOffsetRadius(5)
.WithLabelsPosition(PolarLabelsPosition.Start)
.AddValue(ObservableValue1, "North")
.AddValue(ObservableValue2, "South")
.BuildSeries();
}
public ObservableValue ObservableValue1 { get; set; }
public ObservableValue ObservableValue2 { get; set; }
public IEnumerable<ISeries> Series { get; set; }
[RelayCommand]
public void DoRandomChange()
{
// modifying the Value property updates and animates the chart automatically
ObservableValue1.Value = _random.Next(0, 100);
ObservableValue2.Value = _random.Next(0, 100);
}
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="MauiSample.Pies.Gauge5.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.Gauge5;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}" Text="Change Value"></Button>
<lvc:PieChart
Grid.Row="1"
Series="{Binding Series}"
InitialRotation="-90"
Total="100"
MaxAngle="270"
LegendPosition="Bottom">
</lvc:PieChart>
</Grid>
</ContentPage>