forked from syncfusion/xamarin-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RangeNavigator.cs
102 lines (81 loc) · 3.71 KB
/
RangeNavigator.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
#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 Com.Syncfusion.Charts.Enums;
using Com.Syncfusion.Rangenavigator;
using Java.Util;
namespace SampleBrowser
{
public class RangeNavigator : SamplePage
{
SfChart chartTop;
public override View GetSampleContent(Context context)
{
LayoutInflater layoutInflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
View view = layoutInflater.Inflate(Resource.Layout.range_navigator_getting_Started, null);
chartTop = view.FindViewById<SfChart>(Resource.Id.TopChart);
UpdateChart(chartTop, Visibility.Visible);
SfDateTimeRangeNavigator sfRangeNavigator = view.FindViewById<SfDateTimeRangeNavigator>(Resource.Id.RangeNavigator);
Calendar min = new GregorianCalendar(2015, 0, 1);
Calendar max = new GregorianCalendar(2015, 11, 31);
sfRangeNavigator.Minimum = min.Time;
sfRangeNavigator.Maximum = max.Time;
Calendar visibleMinimum = new GregorianCalendar(2015, 4, 1);
Calendar visibleMaximum = new GregorianCalendar(2015, 7, 1);
sfRangeNavigator.ViewRangeStart = visibleMinimum.Time;
sfRangeNavigator.ViewRangeEnd = visibleMaximum.Time;
View contentView = sfRangeNavigator.Content;
SfChart sfchart = new SfChart(context) { PrimaryAxis = new DateTimeAxis() { Visibility = Visibility.Gone, ShowMajorGridLines = false }, SecondaryAxis = new NumericalAxis() { Visibility = Visibility.Gone, ShowMajorGridLines = false } };
sfchart.Series.Add(new SplineAreaSeries()
{
ItemsSource = MainPage.GetDateTimeValue(),
XBindingPath = "Date",
YBindingPath = "YValue",
Alpha = 0.5f
});
sfRangeNavigator.Content = sfchart;
sfRangeNavigator.RangeChanged += sfRangeNavigator_RangeChanged;
return view;
}
void sfRangeNavigator_RangeChanged(object sender, SfDateTimeRangeNavigator.RangeChangedEventArgs e)
{
((DateTimeAxis)chartTop.PrimaryAxis).Minimum = e.ViewRangeStart;
((DateTimeAxis)chartTop.PrimaryAxis).Maximum = e.ViewRangeEnd;
}
SfChart UpdateChart(SfChart chart, Visibility axisVisibility)
{
DateTimeAxis dateTimeAxis = new DateTimeAxis();
dateTimeAxis.Visibility = axisVisibility;
dateTimeAxis.LabelStyle.LabelFormat = "dd/MMM";
dateTimeAxis.ShowMajorGridLines = axisVisibility == Visibility.Visible ? true : false;
chart.PrimaryAxis = dateTimeAxis;
NumericalAxis numericalAxis = new NumericalAxis();
numericalAxis.Visibility = axisVisibility;
numericalAxis.ShowMajorGridLines = axisVisibility == Visibility.Visible ? true : false;
chart.SecondaryAxis = numericalAxis;
chart.Series.Add(new SplineAreaSeries()
{
ItemsSource = MainPage.GetDateTimeValue(),
XBindingPath = "Date",
YBindingPath = "YValue",
Alpha = 0.5f
});
return chart;
}
}
}