BasicsStackedRowExample.cs
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Windows.Forms;
using LiveCharts;
using LiveCharts.Wpf;
namespace Test.UC
{
public partial class BasicsStackedRowExample : Form
{
public BasicsStackedRowExample()
{
InitializeComponent();
cartesianChart1.Series = new SeriesCollection
{
new StackedRowSeries
{
Values = new ChartValues<double> {4, 5, 6, 8},
StackMode = StackMode.Percentage,
DataLabels = true,
LabelPoint = p => p.X.ToString()
},
new StackedRowSeries
{
Values = new ChartValues<double> {2, 5, 6, 7},
StackMode = StackMode.Percentage,
DataLabels = true,
LabelPoint = p => p.X.ToString()
}
};
//adding series updates and animates the chart
cartesianChart1.Series.Add(new StackedRowSeries
{
Values = new ChartValues<double> { 6, 2, 7 },
StackMode = StackMode.Percentage,
DataLabels = true,
LabelPoint = p => p.X.ToString()
});
//adding values also updates and animates
cartesianChart1.Series[2].Values.Add(4d);
cartesianChart1.AxisY.Add(new Axis
{
Title = "Browser",
Labels = new[] {"Chrome", "Mozilla", "Opera", "IE"}
});
cartesianChart1.AxisX.Add(new Axis
{
LabelFormatter = val => val.ToString("P")
});
var tooltip = new DefaultTooltip {SelectionMode = TooltipSelectionMode.SharedYValues};
cartesianChart1.DataTooltip = tooltip;
}
}
}