-
Notifications
You must be signed in to change notification settings - Fork 204
/
Copy pathSunburstChart.cs
129 lines (105 loc) · 4.61 KB
/
SunburstChart.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
122
123
124
125
126
127
128
129
#region Copyright Syncfusion Inc. 2001 - 2018
// Copyright Syncfusion Inc. 2001 - 2018. 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 System;
using Syncfusion.SfSunburstChart.Android;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Android.Runtime;
namespace SampleBrowser
{
[Preserve(AllMembers = true)]
public class SunburstChart :SamplePage
{
SfSunburstChart chart;
public override View GetSampleContent(Context context)
{
var Data = new ObservableCollection<SunburstModel>();
Data.Add(new SunburstModel() { Quarter = "Q1", Month = "Jan", Sales = 11 });
Data.Add(new SunburstModel() { Quarter = "Q1", Month = "Feb", Sales = 8 });
Data.Add(new SunburstModel() { Quarter = "Q1", Month = "Mar", Sales = 5 });
Data.Add(new SunburstModel() { Quarter = "Q2", Month = "Apr", Sales = 13 });
Data.Add(new SunburstModel() { Quarter = "Q2", Month = "May", Sales = 12 });
Data.Add(new SunburstModel() { Quarter = "Q2", Month = "Jun", Sales = 17 });
Data.Add(new SunburstModel() { Quarter = "Q3", Month = "Jul", Sales = 5 });
Data.Add(new SunburstModel() { Quarter = "Q3", Month = "Aug", Sales = 4 });
Data.Add(new SunburstModel() { Quarter = "Q3", Month = "Sep", Sales = 5 });
Data.Add(new SunburstModel() { Quarter = "Q4", Month = "Oct", Sales = 7 });
Data.Add(new SunburstModel() { Quarter = "Q4", Month = "Nov", Sales = 18 });
Data.Add(new SunburstModel() { Quarter = "Q4", Month = "Dec", Week = "W1", Sales = 5 });
Data.Add(new SunburstModel() { Quarter = "Q4", Month = "Dec", Week = "W2", Sales = 5 });
Data.Add(new SunburstModel() { Quarter = "Q4", Month = "Dec", Week = "W3", Sales = 5 });
Data.Add(new SunburstModel() { Quarter = "Q4", Month = "Dec", Week = "W4", Sales = 5 });
chart = new SfSunburstChart(context);
chart.ItemsSource = Data;
chart.Radius = 0.95;
chart.ValueMemberPath = "Sales";
var levels = new SunburstLevelCollection()
{
new SunburstHierarchicalLevel() { GroupMemberPath = "Quarter"},
new SunburstHierarchicalLevel() { GroupMemberPath = "Month"},
new SunburstHierarchicalLevel() { GroupMemberPath = "Week"}
};
chart.Levels = levels;
chart.EnableAnimation = true;
chart.Title.IsVisible = true;
chart.Title.Margin = new Thickness(10, 5, 5, 5);
chart.Title.Text = "Sales Performance";
chart.Title.TextSize = 20;
chart.Legend.IsVisible = true;
chart.DataLabel.ShowLabel = true;
chart.TooltipSettings = new CustomTooltip(context);
chart.TooltipSettings.ShowTooltip = true;
return chart;
}
}
public class CustomTooltip : SunburstTooltipSettings
{
Context context;
public CustomTooltip(Context con)
{
context = con;
}
public override View GetView(SunburstSegment segment)
{
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.Orientation = Orientation.Vertical;
TextView textView = new TextView(context);
textView.SetTextColor(Color.White);
textView.Text = "Category : " + segment.Category;
TextView textView1 = new TextView(context);
textView1.SetTextColor(Color.White);
textView1.Text = "Value : " + segment.Value;
linearLayout.AddView(textView);
linearLayout.AddView(textView1);
return linearLayout;
}
}
[Preserve(AllMembers = true)]
public class SunburstModel
{
public string Category { get; set; }
public string Country { get; set; }
public string JobDescription { get; set; }
public string JobGroup { get; set; }
public string JobRole { get; set; }
public double EmployeesCount { get; set; }
public string Quarter { get; set; }
public string Month { get; set; }
public string Week { get; set; }
public double Sales { get; set; }
public string Continent { get; set; }
public string State { get; set; }
public double Population { get; set; }
}
}