-
Notifications
You must be signed in to change notification settings - Fork 204
/
StackingBar.cs
82 lines (71 loc) · 3.38 KB
/
StackingBar.cs
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.OS;
using Android.Views;
using Com.Syncfusion.Charts;
using Com.Syncfusion.Charts.Enums;
namespace SampleBrowser
{
public class StackingBar : SamplePage
{
public override View GetSampleContent(Context context)
{
var chart = new SfChart(context);
chart.Title.Text = "Sales Comparison";
chart.Title.TextSize = 15;
chart.SetBackgroundColor(Color.White);
chart.Legend.Visibility = Visibility.Visible;
chart.Legend.ToggleSeriesVisibility = true;
chart.Legend.DockPosition = ChartDock.Bottom;
chart.Legend.IconHeight = 14;
chart.Legend.IconWidth = 14;
chart.ColorModel.ColorPalette = ChartColorPalette.Natural;
CategoryAxis PrimaryAxis = new CategoryAxis();
PrimaryAxis.ShowMajorGridLines = false;
PrimaryAxis.EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift;
PrimaryAxis.LabelPlacement = LabelPlacement.BetweenTicks;
chart.PrimaryAxis = PrimaryAxis;
NumericalAxis numericalAxis = new NumericalAxis();
numericalAxis.EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift;
numericalAxis.Minimum = -20;
numericalAxis.Maximum = 60;
numericalAxis.Interval = 20;
numericalAxis.LineStyle.StrokeWidth = 0;
numericalAxis.MajorTickStyle.TickSize = 0;
numericalAxis.LabelStyle.LabelFormat = "#'%'";
chart.SecondaryAxis = numericalAxis;
StackingBarSeries stackingBarSeries = new StackingBarSeries();
stackingBarSeries.EnableAnimation = true;
stackingBarSeries.Label = "Apple";
stackingBarSeries.ItemsSource = MainPage.GetStackedBarData1();
stackingBarSeries.XBindingPath = "XValue";
stackingBarSeries.YBindingPath = "YValue";
stackingBarSeries.LegendIcon = ChartLegendIcon.SeriesType;
StackingBarSeries stackingBarSeries1 = new StackingBarSeries();
stackingBarSeries1.EnableAnimation = true;
stackingBarSeries1.Label = "Orange";
stackingBarSeries1.ItemsSource = MainPage.GetStackedBarData2();
stackingBarSeries1.XBindingPath = "XValue";
stackingBarSeries1.YBindingPath = "YValue";
stackingBarSeries1.LegendIcon = ChartLegendIcon.SeriesType;
StackingBarSeries stackingBarSeries2 = new StackingBarSeries();
stackingBarSeries2.EnableAnimation = true;
stackingBarSeries2.Label = "Wastage";
stackingBarSeries2.ItemsSource = MainPage.GetStackedBarData3();
stackingBarSeries2.XBindingPath = "XValue";
stackingBarSeries2.YBindingPath = "YValue";
stackingBarSeries2.LegendIcon = ChartLegendIcon.SeriesType;
chart.Series.Add(stackingBarSeries);
chart.Series.Add(stackingBarSeries1);
chart.Series.Add(stackingBarSeries2);
stackingBarSeries.TooltipEnabled = true;
stackingBarSeries1.TooltipEnabled = true;
stackingBarSeries2.TooltipEnabled = true;
stackingBarSeries.EnableAnimation = true;
stackingBarSeries1.EnableAnimation = true;
stackingBarSeries2.EnableAnimation = true;
return chart;
}
}
}