-
Notifications
You must be signed in to change notification settings - Fork 11
/
ThemeManager3DChartFragment.cs
137 lines (117 loc) · 4.98 KB
/
ThemeManager3DChartFragment.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
130
131
132
133
134
135
136
137
using Android.Widget;
using SciChart.Charting.Themes;
using SciChart.Charting3D.Model;
using SciChart.Charting3D.Model.DataSeries.Xyz;
using SciChart.Charting3D.Modifiers;
using SciChart.Charting3D.Visuals;
using SciChart.Charting3D.Visuals.Axes;
using SciChart.Charting3D.Visuals.Camera;
using SciChart.Charting3D.Visuals.PointMarkers;
using SciChart.Charting3D.Visuals.RenderableSeries.Scatter;
using SciChart.Data.Model;
using Xamarin.Examples.Demo.Data;
using Xamarin.Examples.Demo;
using System.Drawing;
using Xamarin.Examples.Demo.Droid.Components;
using Xamarin.Examples.Demo.Droid.Fragments.Base;
namespace Xamarin.Examples.Demo.Droid.Fragments.Examples3D
{
[Example3DDefinition("Theme Manager 3D Chart", description: "Styling Chart3D via the ThemeManager", icon: ExampleIcon.Themes)]
class ThemeManager3DChartFragment : ExampleBaseFragment
{
private const int BlackSteel = 0;
private const int BrightSpark = 1;
private const int Chrome = 2;
private const int Electric = 3;
private const int ExpressionDark = 4;
private const int ExpressionLight = 5;
private const int Oscilloscope = 6;
private const int SciChartV4Dark = 7;
public SciChartSurface3D Surface => View.FindViewById<SciChartSurface3D>(Resource.Id.chart3d);
public Spinner ThemeSelector => View.FindViewById<Spinner>(Resource.Id.themeSelector);
public override int ExampleLayoutId => Resource.Layout.Example_ThemeManager3D_Fragment;
protected override void InitExample()
{
InitializeUIHandlers();
var dataManager = DataManager.Instance;
var dataSeries3D = new XyzDataSeries3D<double, double, double>();
var metadataProvider = new PointMetadataProvider3D();
for (int i = 0; i < 1250; i++)
{
var x = dataManager.GetGaussianRandomNumber(5, 1.5);
var y = dataManager.GetGaussianRandomNumber(5, 1.5);
var z = dataManager.GetGaussianRandomNumber(5, 1.5);
dataSeries3D.Append(x, y, z);
var color = dataManager.GetRandomColor();
var scale = dataManager.GetRandomScale();
metadataProvider.Metadata.Add(new PointMetadata3D(color, scale));
}
var pointMarker3D = new SpherePointMarker3D()
{
FillColor = Color.Lime,
Size = 2f
};
var renderableSeries3D = new ScatterRenderableSeries3D()
{
PointMarker = pointMarker3D,
DataSeries = dataSeries3D,
MetadataProvider = metadataProvider
};
using (Surface.SuspendUpdates())
{
Surface.XAxis = new NumericAxis3D() { GrowBy = new DoubleRange(0.1, 0.1) };
Surface.YAxis = new NumericAxis3D() { GrowBy = new DoubleRange(0.1, 0.1) };
Surface.ZAxis = new NumericAxis3D() { GrowBy = new DoubleRange(0.1, 0.1) };
Surface.Camera = new Camera3D();
Surface.RenderableSeries.Add(renderableSeries3D);
Surface.ChartModifiers = new ChartModifier3DCollection
{
new PinchZoomModifier3D(),
new OrbitModifier3D(),
new ZoomExtentsModifier3D()
};
}
}
private void InitializeUIHandlers()
{
ThemeSelector.Adapter = new SpinnerStringAdapter(Activity, Resource.Array.style_list);
ThemeSelector.SetSelection(7);
ThemeSelector.ItemSelected += (sender, args) => { SetTheme(args.Position); };
}
private void SetTheme(int position)
{
int themeId;
switch (position)
{
case BlackSteel:
themeId = Resource.Style.SciChart_BlackSteel;
break;
case BrightSpark:
themeId = Resource.Style.SciChart_Bright_Spark;
break;
case Chrome:
themeId = Resource.Style.SciChart_ChromeStyle;
break;
case Electric:
themeId = Resource.Style.SciChart_ElectricStyle;
break;
case ExpressionDark:
themeId = Resource.Style.SciChart_ExpressionDarkStyle;
break;
case ExpressionLight:
themeId = Resource.Style.SciChart_ExpressionLightStyle;
break;
case Oscilloscope:
themeId = Resource.Style.SciChart_OscilloscopeStyle;
break;
case SciChartV4Dark:
themeId = Resource.Style.SciChart_SciChartv4DarkStyle;
break;
default:
themeId = ThemeManager.DefaultTheme;
break;
}
Surface.Theme = themeId;
}
}
}