forked from syncfusion/xamarin-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnnotationCustomization.cs
100 lines (88 loc) · 3.66 KB
/
AnnotationCustomization.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
#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.
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Com.Syncfusion.Charts;
using Android.Graphics;
namespace SampleBrowser
{
class AnnotationCustomization:SamplePage
{
SfChart chart;
public override View GetSampleContent(Context context)
{
chart = new SfChart(context);
chart.SetBackgroundColor(Color.White);
chart.AreaBackgroundColor = Color.Rgb(245, 245, 245);
NumericalAxis categoryaxis = new NumericalAxis();
categoryaxis.ShowMajorGridLines = false;
categoryaxis.Minimum = 0;
categoryaxis.Maximum = 4;
categoryaxis.LineStyle.StrokeColor = Color.White;
chart.PrimaryAxis = categoryaxis;
NumericalAxis numericalaxis = new NumericalAxis();
numericalaxis.ShowMajorGridLines = false;
numericalaxis.Minimum = 20;
numericalaxis.Maximum = 70;
numericalaxis.LineStyle.StrokeColor = Color.White;
chart.SecondaryAxis = numericalaxis;
LineAnnotation lineAnnotation = new LineAnnotation();
lineAnnotation.Text = "Line";
lineAnnotation.X1 = 2.5;
lineAnnotation.X2 = 3.5;
lineAnnotation.Y1 = 52;
lineAnnotation.Y2 = 63;
lineAnnotation.LabelStyle.MarginTop = 5;
lineAnnotation.LabelStyle.MarginRight = 5;
lineAnnotation.LabelStyle.MarginLeft = 5;
lineAnnotation.LabelStyle.MarginBottom = 5;
lineAnnotation.LineCap = ChartLineCap.Arrow;
HorizontalLineAnnotation horizontalAnnotation = new HorizontalLineAnnotation();
horizontalAnnotation.Y1 = 45;
horizontalAnnotation.Text = "Horizontal Line";
horizontalAnnotation.LineCap = ChartLineCap.Arrow;
horizontalAnnotation.ShowAxisLabel = true;
VerticalLineAnnotation verticalAnnotation = new VerticalLineAnnotation();
verticalAnnotation.X1 = 2;
verticalAnnotation.Text = "Vertical Line";
verticalAnnotation.LineCap = ChartLineCap.Arrow;
verticalAnnotation.ShowAxisLabel = true;
RectangleAnnotation RectAnnotation = new RectangleAnnotation();
RectAnnotation.X1 = 0.5;
RectAnnotation.X2 = 1.5;
RectAnnotation.Y1 = 25;
RectAnnotation.Y2 = 35;
RectAnnotation.Text = "Rectangle";
EllipseAnnotation eleAnnotation = new EllipseAnnotation();
eleAnnotation.X1 = 2.5;
eleAnnotation.X2 = 3.5;
eleAnnotation.Y1 = 25;
eleAnnotation.Y2 = 35;
eleAnnotation.Text = "Ellipse";
TextAnnotation textAnnotation = new TextAnnotation();
textAnnotation.X1 = 1;
textAnnotation.Y1 = 57.5;
textAnnotation.Text = "Text Annotation";
chart.Annotations.Add(textAnnotation);
chart.Annotations.Add(eleAnnotation);
chart.Annotations.Add(RectAnnotation);
chart.Annotations.Add(verticalAnnotation);
chart.Annotations.Add(horizontalAnnotation);
chart.Annotations.Add(lineAnnotation);
return chart;
}
}
}