-
Notifications
You must be signed in to change notification settings - Fork 204
/
VerticalChart.cs
109 lines (94 loc) · 3.17 KB
/
VerticalChart.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
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 Java.Lang;
using Com.Syncfusion.Charts.Enums;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
namespace SampleBrowser
{
public class VerticalChart : SamplePage
{
ObservableCollection<DataPoint> datas1;
SfChart sfChart;
int count = 0;
public override View GetSampleContent(Context context) {
datas1 = new ObservableCollection<DataPoint>();
sfChart = new SfChart(context);
sfChart.ColorModel.ColorPalette = ChartColorPalette.Natural;
sfChart.Title.Text ="Seismograph analysis of a country";
sfChart.Title.TextSize = 15;
sfChart.Legend.Visibility = Visibility.Visible;
sfChart.Legend.ToggleSeriesVisibility = true;
NumericalAxis primaryAxis = new NumericalAxis();
primaryAxis.Title.Text ="Time (s)";
primaryAxis.ShowMajorGridLines = false;
sfChart.PrimaryAxis = primaryAxis;
NumericalAxis numericalAxis = new NumericalAxis() {
Minimum = -15,
Maximum = 15,
};
numericalAxis.Title.Text ="Velocity (m/s)";
numericalAxis.ShowMajorGridLines = false;
sfChart.SecondaryAxis = numericalAxis;
FastLineSeries fastLineSeries = new FastLineSeries();
fastLineSeries.ItemsSource = datas1;
fastLineSeries.XBindingPath = "XValue";
fastLineSeries.YBindingPath = "YValue";
fastLineSeries.Label="Indonesia";
fastLineSeries.Transposed = true;
sfChart.Series.Add(fastLineSeries);
Random random = new Random();
for (int i = 1; i < 50; i++)
{
datas1.Add(new DataPoint(i, random.Next(-3, 3)));
}
UpdateData();
return sfChart;
}
private async void UpdateData()
{
bool isFlag = true;
while (isFlag)
{
await Task.Delay(10);
count = count + 1;
Random random = new Random();
int index = datas1.Count();
if (count > 350)
{
isFlag =false;
}
else if (count > 300)
{
datas1.Add(new DataPoint(index, random.Next(0, 0)));
}
else if (count > 250)
{
datas1.Add(new DataPoint(index, random.Next(-2, 1)));
}
else if (count > 180)
{
datas1.Add(new DataPoint(index,random.Next(-3, 2)));
}
else if (count > 100)
{
datas1.Add(new DataPoint(index,random.Next(-7, 6)));
}
else
{
datas1.Add(new DataPoint(index, random.Next(-9, 9)));
}
index++;
}
}
}
}