-
Notifications
You must be signed in to change notification settings - Fork 204
/
Pyramid.cs
86 lines (75 loc) · 3.21 KB
/
Pyramid.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Com.Syncfusion.Charts;
using Android.Graphics;
using Com.Syncfusion.Charts.Enums;
namespace SampleBrowser
{
public class Pyramid : SamplePage
{
SfChart chart;
List<String> overflowMode;
public override View GetSampleContent(Context context)
{
chart = new SfChart(context);
chart.Title.Text = "Food Comparison Chart";
chart.Title.TextSize = 15;
chart.SetBackgroundColor(Color.White);
chart.Legend.Visibility = Visibility.Visible;
chart.Legend.DockPosition = ChartDock.Bottom;
chart.Legend.IconHeight = 14;
chart.Legend.IconWidth = 14;
chart.Legend.ToggleSeriesVisibility = true;
chart.Legend.OverflowMode = ChartLegendOverflowMode.Wrap;
PyramidSeries pyramid = new PyramidSeries();
pyramid.XBindingPath = "XValue";
pyramid.YBindingPath = "YValue";
pyramid.ItemsSource = MainPage.GetPyramidData();
pyramid.ColorModel.ColorPalette = ChartColorPalette.Natural;
pyramid.TooltipEnabled = true;
pyramid.StrokeWidth = 1;
pyramid.StrokeColor = Color.White;
chart.Series.Add(pyramid);
ChartTooltipBehavior tooltipBehavior = new ChartTooltipBehavior();
tooltipBehavior.LabelFormat = "##.## cal";
chart.Behaviors.Add(tooltipBehavior);
Spinner selectLabelMode = new Spinner(context, SpinnerMode.Dialog);
overflowMode = new List<String>() { "Wrap", "Scroll" };
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
(context, Android.Resource.Layout.SimpleSpinnerItem, overflowMode);
dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line);
selectLabelMode.Adapter = dataAdapter;
selectLabelMode.ItemSelected += SelectLabelMode_ItemSelected;
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.SetPadding(20, 0, 20, 30);
linearLayout.SetBackgroundColor(Color.Rgb(236, 235, 242));
linearLayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent,
LinearLayout.LayoutParams.WrapContent);
linearLayout.Orientation = Orientation.Vertical;
linearLayout.SetBackgroundColor(Color.White);
linearLayout.AddView(selectLabelMode);
linearLayout.AddView(chart);
return linearLayout;
}
private void SelectLabelMode_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
{
String selectedItem = overflowMode[e.Position];
if (selectedItem.Equals("Wrap"))
{
chart.Legend.OverflowMode = Com.Syncfusion.Charts.ChartLegendOverflowMode.Wrap;
}
else if (selectedItem.Equals("Scroll"))
{
chart.Legend.OverflowMode = Com.Syncfusion.Charts.ChartLegendOverflowMode.Scroll;
}
}
}
}