-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathBubbleChartFragment.cs
72 lines (63 loc) · 2.9 KB
/
BubbleChartFragment.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
using System;
using System.Linq;
using Android.Views.Animations;
using SciChart.Charting.Model;
using SciChart.Charting.Model.DataSeries;
using SciChart.Charting.Modifiers;
using SciChart.Charting.Visuals;
using SciChart.Charting.Visuals.Animations;
using SciChart.Charting.Visuals.Axes;
using SciChart.Charting.Visuals.RenderableSeries;
using SciChart.Data.Model;
using SciChart.Drawing.Common;
using SciChart.Examples.Demo.Data;
using SciChart.Examples.Demo.Fragments.Base;
using Xamarin.Examples.Demo.Droid.Extensions;
using Xamarin.Examples.Demo.Droid.Fragments.Base;
namespace Xamarin.Examples.Demo.Droid.Fragments.Examples
{
[ExampleDefinition("Bubble Chart", description:"Creates a Bubble Series and Line Chart", icon: ExampleIcon.BubbleChart)]
public class BubbleChartFragment : ExampleBaseFragment
{
public SciChartSurface Surface => View.FindViewById<SciChartSurface>(Resource.Id.chart);
public override int ExampleLayoutId => Resource.Layout.Example_Single_Chart_Fragment;
protected override void InitExample()
{
var xAxis = new DateAxis(Activity) {GrowBy = new DoubleRange(0, 0.1)};
var yAxis = new NumericAxis(Activity) {GrowBy = new DoubleRange(0, 0.1)};
var dataSeries = new XyzDataSeries<DateTime, double, double>();
var tradeDataSource = DataManager.Instance.GetTradeticks().ToArray();
dataSeries.Append(
tradeDataSource.Select(x => x.TradeDate),
tradeDataSource.Select(x => x.TradePrice),
tradeDataSource.Select(x => x.TradeSize));
var lineSeries = new FastLineRenderableSeries
{
DataSeries = dataSeries,
StrokeStyle = new SolidPenStyle(0xFFFF3333, 1.ToDip(Activity))
};
var bubbleSeries = new FastBubbleRenderableSeries
{
DataSeries = dataSeries,
BubbleBrushStyle = new SolidBrushStyle(0x77CCCCCC),
StrokeStyle = new SolidPenStyle(0xFFCCCCCC, 2f.ToDip(Activity)),
ZScaleFactor = 3,
AutoZRange = false,
};
using (Surface.SuspendUpdates())
{
Surface.XAxes.Add(xAxis);
Surface.YAxes.Add(yAxis);
Surface.RenderableSeries.Add(lineSeries);
Surface.RenderableSeries.Add(bubbleSeries);
Surface.ChartModifiers = new ChartModifierCollection
{
new RubberBandXyZoomModifier(),
new ZoomExtentsModifier(),
};
new ScaleAnimatorBuilder(lineSeries, 10600d) { Interpolator = new OvershootInterpolator(), Duration = 1000, StartDelay = 600 }.Start();
new ScaleAnimatorBuilder(bubbleSeries, 10600d) { Interpolator = new OvershootInterpolator(), Duration = 1000, StartDelay = 600 }.Start();
}
}
}
}