270 Degrees Gauge
This web site builds the control from code behind but you could also grab it from the toolbox, this sample also uses a ViewModel to populate the properties of the control(s) in this sample.
View model
using System.Collections.Generic;
using LiveChartsCore;
using LiveChartsCore.Measure;
using CommunityToolkit.Mvvm.ComponentModel;
using LiveChartsCore.SkiaSharpView.Painting;
using SkiaSharp;
using LiveChartsCore.SkiaSharpView.Extensions;
namespace ViewModelsSamples.Pies.Gauge2;
public partial class ViewModel : ObservableObject
{
public IEnumerable<ISeries> Series { get; set; } =
GaugeGenerator.BuildSolidGauge(
new GaugeItem(30, series =>
{
series.Fill = new SolidColorPaint(SKColors.YellowGreen);
series.DataLabelsSize = 50;
series.DataLabelsPaint = new SolidColorPaint(SKColors.Red);
series.DataLabelsPosition = PolarLabelsPosition.ChartCenter;
series.InnerRadius = 75;
}),
new GaugeItem(GaugeItem.Background, series =>
{
series.InnerRadius = 75;
series.Fill = new SolidColorPaint(new SKColor(100, 181, 246, 90));
}));
}
Form code behind
using System.Windows.Forms;
using LiveChartsCore.SkiaSharpView.WinForms;
using ViewModelsSamples.Pies.Gauge2;
namespace WinFormsSample.Pies.Gauge2;
public partial class View : UserControl
{
private readonly PieChart pieChart;
public View()
{
InitializeComponent();
Size = new System.Drawing.Size(50, 50);
var viewModel = new ViewModel();
pieChart = new PieChart
{
Series = viewModel.Series,
InitialRotation = -225,
MaxAngle = 270,
MinValue = 0,
MaxValue = 100,
// out of livecharts properties...
Location = new System.Drawing.Point(0, 0),
Size = new System.Drawing.Size(50, 50),
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
};
Controls.Add(pieChart);
}
}