Doughnut
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 LiveChartsCore;
using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.Generic;
using LiveChartsCore.SkiaSharpView.Extensions;
namespace ViewModelsSamples.Pies.Doughnut;
public partial class ViewModel : ObservableObject
{
// you can convert any array, list or IEnumerable<T> to a pie series collection:
public IEnumerable<ISeries> Series { get; set; } =
new[] { 2, 4, 1, 4, 3 }.AsPieSeries((value, series) =>
{
series.MaxRadialColumnWidth = 60;
});
}
Form code behind
using System.Windows.Forms;
using LiveChartsCore.SkiaSharpView.WinForms;
using ViewModelsSamples.Pies.Doughnut;
namespace WinFormsSample.Pies.Doughnut;
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,
// 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);
}
}