/
BubbleChartViewController.cs
71 lines (60 loc) · 2.82 KB
/
BubbleChartViewController.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
using System;
using System.Linq;
using SciChart.Examples.Demo.Data;
using SciChart.Examples.Demo.Fragments.Base;
using SciChart.iOS.Charting;
using Xamarin.Examples.Demo.iOS.Resources.Layout;
using Xamarin.Examples.Demo.iOS.Views.Base;
namespace Xamarin.Examples.Demo.iOS.Views.Examples
{
[ExampleDefinition("Bubble Chart", description: "Generates a Line and Bubble series chart in code", icon: ExampleIcon.BubbleChart)]
public class BubbleChartViewController : ExampleBaseViewController
{
public override Type ExampleViewType => typeof(SingleChartViewLayout);
public SCIChartSurface Surface => ((SingleChartViewLayout)View).SciChartSurface;
protected override void InitExample()
{
var xAxis = new SCIDateTimeAxis { GrowBy = new SCIDoubleRange(0.0, 0.1) };
var yAxis = new SCINumericAxis { GrowBy = new SCIDoubleRange(0, 0.1) };
var dataSeries = new XyzDataSeries<DateTime, double, double>();
var tradeDataSource = DataManager.Instance.GetTradeticks().ToArray();
dataSeries.Append(
tradeDataSource.Select(x => x.TradeDate).ToArray(),
tradeDataSource.Select(x => x.TradePrice).ToArray(),
tradeDataSource.Select(x => x.TradeSize).ToArray());
var lineSeries = new SCIFastLineRenderableSeries
{
DataSeries = dataSeries,
StrokeStyle = new SCISolidPenStyle(0xFFFF3333, 1f)
};
var lineAnimation = new SCIScaleRenderableSeriesAnimation(3, SCIAnimationCurve.EaseOutElastic);
lineAnimation.StartAfterDelay(0.3f);
lineSeries.AddAnimation(lineAnimation);
var bubbleSeries = new SCIBubbleRenderableSeries
{
DataSeries = dataSeries,
//Style = new SCIBubbleSeriesStyle { Detalization = 40, },
ZScaleFactor = 1,
AutoZRange = false,
BubbleBrushStyle = new SCISolidBrushStyle(0x50CCCCCC),
StrokeStyle = new SCISolidPenStyle(0x90CCCCCC, 2f)
};
var bubbleAnimation = new SCIScaleRenderableSeriesAnimation(3, SCIAnimationCurve.EaseOutElastic);
bubbleAnimation.StartAfterDelay(0.3f);
bubbleSeries.AddAnimation(bubbleAnimation);
using (Surface.SuspendUpdates())
{
Surface.XAxes.Add(xAxis);
Surface.YAxes.Add(yAxis);
Surface.RenderableSeries.Add(lineSeries);
Surface.RenderableSeries.Add(bubbleSeries);
Surface.ChartModifiers = new SCIChartModifierCollection
{
new SCIZoomPanModifier(),
new SCIPinchZoomModifier(),
new SCIZoomExtentsModifier()
};
}
}
}
}