Files
aistudio-wpf-diagram/Live-Charts-master/Examples/Wpf/CartesianChart/Basic Stacked Bar/BasicStackedColumnExample.xaml.cs

55 lines
1.6 KiB
C#
Raw Normal View History

2021-07-23 09:42:22 +08:00
using System;
using System.Windows.Controls;
using LiveCharts;
using LiveCharts.Wpf;
namespace Wpf.CartesianChart.Basic_Stacked_Bar
{
/// <summary>
/// Interaction logic for StackedColumnExample.xaml
/// </summary>
public partial class BasicStackedColumnExample : UserControl
{
public BasicStackedColumnExample()
{
InitializeComponent();
SeriesCollection = new SeriesCollection
{
new StackedColumnSeries
{
Values = new ChartValues<double> {4, 5, 6, 8},
StackMode = StackMode.Values, // this is not necessary, values is the default stack mode
DataLabels = true
},
new StackedColumnSeries
{
Values = new ChartValues<double> {2, 5, 6, 7},
StackMode = StackMode.Values,
DataLabels = true
}
};
//adding series updates and animates the chart
SeriesCollection.Add(new StackedColumnSeries
{
Values = new ChartValues<double> {6, 2, 7},
StackMode = StackMode.Values
});
//adding values also updates and animates
SeriesCollection[2].Values.Add(4d);
Labels = new[] {"Chrome", "Mozilla", "Opera", "IE"};
Formatter = value => value + " Mill";
DataContext = this;
}
public SeriesCollection SeriesCollection { get; set; }
public string[] Labels { get; set; }
public Func<double, string> Formatter { get; set; }
}
}