-
Notifications
You must be signed in to change notification settings - Fork 11
/
SplineMountainChartFragment.cs
67 lines (60 loc) · 2.7 KB
/
SplineMountainChartFragment.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
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.PointMarkers;
using SciChart.Charting.Visuals.RenderableSeries;
using SciChart.Data.Model;
using SciChart.Drawing.Common;
using Xamarin.Examples.Demo.Data;
using Xamarin.Examples.Demo.Droid.Extensions;
using Xamarin.Examples.Demo.Droid.Fragments.Base;
namespace Xamarin.Examples.Demo.Droid.Fragments.Examples
{
[ExampleDefinition("Spline Mountain Chart", description: "Create a spline Mountain / Area Chart", icon: ExampleIcon.MountainChart)]
public class SplineMountainChartFragment : 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 NumericAxis(Activity) {GrowBy = new DoubleRange(0.1, 0.1)};
var yAxis = new NumericAxis(Activity) {GrowBy = new DoubleRange(0.2, 0.2)};
var dataSeries = new XyDataSeries<int, int>();
var yValues = new[] {50, 35, 61, 58, 50, 50, 40, 53, 55, 23, 45, 12, 59, 60};
for (int i = 0; i < yValues.Length; i++)
{
dataSeries.Append(i, yValues[i]);
}
var rSeries = new SplineMountainRenderableSeries
{
DataSeries = dataSeries,
StrokeStyle = new SolidPenStyle(0xAAFFC9A8, 2f.ToDip(Activity)),
AreaStyle = new LinearGradientBrushStyle(0, 0, 1, 1, 0xAAFF8D42, 0x88090E11),
PointMarker = new EllipsePointMarker
{
Width = 7.ToDip(Activity),
Height = 7.ToDip(Activity),
StrokeStyle = new SolidPenStyle(0xFF006400, 1f.ToDip(Activity)),
FillStyle = new SolidBrushStyle(0xFFFFFFFF)
}
};
using (Surface.SuspendUpdates())
{
Surface.XAxes.Add(xAxis);
Surface.YAxes.Add(yAxis);
Surface.RenderableSeries.Add(rSeries);
Surface.ChartModifiers = new ChartModifierCollection
{
new ZoomPanModifier(),
new PinchZoomModifier(),
new ZoomExtentsModifier(),
};
new WaveAnimatorBuilder(rSeries) {Interpolator = new DecelerateInterpolator(), Duration = 3000, StartDelay = 350}.Start();
}
}
}
}