This issue recommends LiveCharts2, a simple, flexible, interactive, and powerful chart library for.NET.
LiveCharts2 (v2) is an evolution of LiveCharts (v0) that fixes the major design issues of its predecessor with a greater focus on running anywhere, increasing flexibility without losing functionality already available in v0. LiveCharts2 runs on WPF, WinForms, Xamarin, Avalonia, WinUI, UWP, Blazor-wasm, and MAUI.
Installation use
In Visual Studio, Solution Explorer then right click Dependencies then Manage NuGet Packages, enable the “Include pre-release” check box, Then search the view of the target platform in the Browse TAB:
- LiveChartsCore.SkiaSharpView.WPF
- LiveChartsCore.SkiaSharpView.WinForms
- LiveChartsCore.SkiaSharpView.Avalonia
- LiveChartsCore.SkiaSharpView.XamarinForms
- LiveChartsCore.SkiaSharpView.UWP
- LiveChartsCore.SkiaSharpView.WinUI
- LiveChartsCore.SkiaSharpView.Blazor
- LiveChartsCore.SkiaSharpView.Maui
LiveCharts2 can also be used in a console application or on the server side where only the core package is installed and ISkiaSharpChart objects are used, reference code:
using System.Windows.Controls;
using LiveChartsCore.SkiaSharpView.SKCharts;
using LiveChartsCore.SkiaSharpView.WPF;
namespace WPFSample.General.ChartToImage;
/// < summary>
/// Interaction logic for View.xaml
/// < /summary>
public partial class View : UserControl
{
public View()
{
InitializeComponent();
// Load view
// Render image
Loaded += View_Loaded;
}
private void View_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
CreateImageFromCartesianControl();
CreateImageFromPieControl();
CreateImageFromGeoControl();
}
private void CreateImageFromCartesianControl()
{
//You can take any chart in the UI and build an image from it
var chartControl = (CartesianChart)FindName("cartesianChart");
var skChart = new SKCartesianChart(chartControl) { Width = 900, Height = 600, };
skChart.SaveImage("CartesianImageFromControl.png");
}
private void CreateImageFromPieControl()
{
var chartControl = (PieChart)FindName("pieChart");
var skChart = new SKPieChart(chartControl) { Width = 900, Height = 600, };
skChart.SaveImage("PieImageFromControl.png");
}
private void CreateImageFromGeoControl()
{
var chartControl = (GeoMap)FindName("geoChart");
var skChart = new SKGeoMap(chartControl) { Width = 900, Height = 600, };
skChart.SaveImage("MapImageFromControl.png");
}
}
Other charts
- Basic line chart
- Bar chart
- Pile graph
- Area map
- Ladder chart
- Scatter plot
- Open high close low
- Pie chart
- Thermal map
< p data – track = “35” > v2.0 is currently a test version, using MIT open source licenses, you can use: from NuGet install https://github.com/beto-rodriguez/LiveCharts2/issues/35.