forked from syncfusion/xamarin-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChartAnnotation.cs
109 lines (93 loc) · 3.57 KB
/
ChartAnnotation.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
#region Copyright Syncfusion Inc. 2001 - 2019
// Copyright Syncfusion Inc. 2001 - 2019. 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.
using CoreAnimation;
#endregion
using System;
using Syncfusion.SfChart.iOS;
#if __UNIFIED__
using CoreGraphics;
using Foundation;
using UIKit;
#else
using MonoTouch.Foundation;
using MonoTouch.CoreGraphics;
using MonoTouch.UIKit;
using nint = System.Int32;
using nuint = System.Int32;
using CGSize = System.Drawing.SizeF;
using CGRect = System.Drawing.RectangleF;
#endif
namespace SampleBrowser
{
public class ChartAnnotation : SampleView
{
public ChartAnnotation()
{
SFChart chart = new SFChart();
chart.PrimaryAxis = new SFNumericalAxis()
{
Minimum = new NSNumber(0),
Maximum = new NSNumber(4),
ShowMajorGridLines = false
};
chart.SecondaryAxis = new SFNumericalAxis()
{
Minimum = new NSNumber(20),
Maximum = new NSNumber(70),
ShowMajorGridLines = false,
};
VerticalLineAnnotation VerticalLineAnnotation = new VerticalLineAnnotation();
VerticalLineAnnotation.X1 = 2;
VerticalLineAnnotation.LineCap = ChartLineCap.Arrow;
VerticalLineAnnotation.Text = "Vertical Line";
VerticalLineAnnotation.ShowAxisLabel = true;
HorizontalLineAnnotation horizontalLineAnnotation = new HorizontalLineAnnotation();
horizontalLineAnnotation.Y1 = 45;
horizontalLineAnnotation.LineCap = ChartLineCap.Arrow;
horizontalLineAnnotation.Text = "Horizontal Line";
horizontalLineAnnotation.ShowAxisLabel = true;
LineAnnotation lineAnnotation = new LineAnnotation();
lineAnnotation.X1 = 2.5;
lineAnnotation.X2 = 3.5;
lineAnnotation.Y1 = 52;
lineAnnotation.Y2 = 63;
lineAnnotation.LineCap = ChartLineCap.Arrow;
lineAnnotation.Text = "Line";
RectangleAnnotation rectangleAnnotation = new RectangleAnnotation();
rectangleAnnotation.Text = "Rectangle";
rectangleAnnotation.X1 = 0.5;
rectangleAnnotation.X2 = 1.5;
rectangleAnnotation.Y1 = 25;
rectangleAnnotation.Y2 = 35;
EllipseAnnotation ellipseAnnotation = new EllipseAnnotation();
ellipseAnnotation.Text = "Ellipse";
ellipseAnnotation.X1 = 2.5;
ellipseAnnotation.X2 = 3.5;
ellipseAnnotation.Y1 = 25;
ellipseAnnotation.Y2 = 35;
TextAnnotation textAnnotation = new TextAnnotation();
textAnnotation.X1 = 1;
textAnnotation.Y1 = 57.5;
textAnnotation.Text = "Text Annotation";
chart.Annotations.Add(VerticalLineAnnotation);
chart.Annotations.Add(horizontalLineAnnotation);
chart.Annotations.Add(lineAnnotation);
chart.Annotations.Add(rectangleAnnotation);
chart.Annotations.Add(ellipseAnnotation);
chart.Annotations.Add(textAnnotation);
this.AddSubview(chart);
}
public override void LayoutSubviews()
{
foreach (var view in this.Subviews)
{
view.Frame = Bounds;
}
base.LayoutSubviews();
}
}
}