mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-07 10:10:49 +08:00
45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using System;
|
|
using System.Windows.Controls;
|
|
using LiveCharts;
|
|
using LiveCharts.Wpf;
|
|
|
|
namespace Wpf.CartesianChart.Basic_Bars
|
|
{
|
|
public partial class BasicColumn : UserControl
|
|
{
|
|
public BasicColumn()
|
|
{
|
|
InitializeComponent();
|
|
|
|
SeriesCollection = new SeriesCollection
|
|
{
|
|
new ColumnSeries
|
|
{
|
|
Title = "2015",
|
|
Values = new ChartValues<double> { 10, 50, 39, 50 }
|
|
}
|
|
};
|
|
|
|
//adding series will update and animate the chart automatically
|
|
SeriesCollection.Add(new ColumnSeries
|
|
{
|
|
Title = "2016",
|
|
Values = new ChartValues<double> { 11, 56, 42 }
|
|
});
|
|
|
|
//also adding values updates and animates the chart automatically
|
|
SeriesCollection[1].Values.Add(48d);
|
|
|
|
Labels = new[] {"Maria", "Susan", "Charles", "Frida"};
|
|
Formatter = value => value.ToString("N");
|
|
|
|
DataContext = this;
|
|
}
|
|
|
|
public SeriesCollection SeriesCollection { get; set; }
|
|
public string[] Labels { get; set; }
|
|
public Func<double, string> Formatter { get; set; }
|
|
|
|
}
|
|
}
|