forked from syncfusion/xamarin-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PieSeries.cs
121 lines (107 loc) · 4.61 KB
/
PieSeries.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#region Copyright Syncfusion Inc. 2001-2019.
// Copyright Syncfusion Inc. 2001-2019. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// [email protected]. Any infringement will be prosecuted under
// applicable laws.
#endregion
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.OS;
using Android.Views;
using Android.Widget;
using Com.Syncfusion.Charts;
using Com.Syncfusion.Charts.Enums;
using Com.Syncfusion.Navigationdrawer;
using System.Collections.Generic;
namespace SampleBrowser
{
public class Pie : SamplePage
{
PieSeries pieSeries;
TextView groupToValue;
TextView groupMode;
List<string> groupModeType;
public override View GetSampleContent(Context context)
{
var chart = new SfChart(context);
chart.Title.Text = "Sales by Sales Person";
chart.Title.TextSize = 15;
chart.SetBackgroundColor(Android.Graphics.Color.White);
chart.Legend.Visibility = Visibility.Visible;
chart.Legend.ToggleSeriesVisibility = true;
chart.Legend.OverflowMode = ChartLegendOverflowMode.Wrap;
chart.Legend.DockPosition = ChartDock.Bottom;
chart.Legend.IconHeight = 14;
chart.Legend.IconWidth = 14;
pieSeries = new PieSeries();
pieSeries.TooltipEnabled = true;
pieSeries.GroupTo = 25;
pieSeries.ColorModel.ColorPalette = ChartColorPalette.Natural;
pieSeries.ItemsSource = MainPage.GetPieData();
pieSeries.XBindingPath = "XValue";
pieSeries.YBindingPath = "YValue";
pieSeries.DataMarker.ShowLabel = true;
pieSeries.DataMarker.LabelStyle.LabelFormat = "#.#'%'";
pieSeries.EnableAnimation = true;
pieSeries.CircularCoefficient = 0.7;
pieSeries.StrokeWidth = 1;
pieSeries.StrokeColor = Android.Graphics.Color.White;
chart.Series.Add(pieSeries);
return chart;
}
public override View GetPropertyWindowLayout(Android.Content.Context context)
{
int width = (context.Resources.DisplayMetrics.WidthPixels) / 2;
LinearLayout propertylayout = new LinearLayout(context);
propertylayout.Orientation = Android.Widget.Orientation.Vertical;
LinearLayout.LayoutParams layoutParams1 = new LinearLayout.LayoutParams(
width * 2, 2);
groupToValue = new TextView(context);
groupToValue.Text = "GroupTo Value is 25";
groupToValue.SetPadding(5, 20, 0, 20);
SeekBar groupTo = new SeekBar(context);
groupTo.Progress = 25;
groupTo.Max = 40;
groupTo.ProgressChanged += GroupTo_ProgressChanged;
groupMode = new TextView(context);
groupMode.Text = "GroupMode";
Spinner selectLabelMode = new Spinner(context, SpinnerMode.Dialog);
groupModeType = new List<string>() { "Value", "Percentage", "Angle" };
ArrayAdapter<string> dataAdapter = new ArrayAdapter<string>
(context, Android.Resource.Layout.SimpleSpinnerItem, groupModeType);
dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line);
selectLabelMode.Adapter = dataAdapter;
selectLabelMode.ItemSelected += SelectLabelMode_ItemSelected;
propertylayout.AddView(groupToValue);
propertylayout.AddView(groupTo);
propertylayout.AddView(groupMode);
propertylayout.AddView(selectLabelMode);
SeparatorView separate = new SeparatorView(context, width * 2);
separate.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 5);
propertylayout.AddView(separate, layoutParams1);
return propertylayout;
}
void GroupTo_ProgressChanged(object sender, SeekBar.ProgressChangedEventArgs e)
{
groupToValue.Text = "groupToValue is " + ((int)e.Progress).ToString();
pieSeries.GroupTo = (int)e.Progress;
}
void SelectLabelMode_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
{
switch (e.Position)
{
case 0:
pieSeries.GroupMode = PieGroupMode.Value;
break;
case 1:
pieSeries.GroupMode = PieGroupMode.Percentage;
break;
case 2:
pieSeries.GroupMode = PieGroupMode.Angle;
break;
}
}
}
}