Hi, the following test charting does not show Date/Category axis on android as it is showing well on WP (See attached files); can anybody tell me why?
01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.Linq;
04.
using
System.Text;
05.
using
System.Threading.Tasks;
06.
using
Telerik.XamarinForms.Chart;
07.
using
TelerikTests.ViewModel;
08.
using
Xamarin.Forms;
09.
10.
namespace
TelerikTests.View
11.
{
12.
public
class
ChartViewModel
13.
{
14.
private
static
Random random =
new
Random();
15.
16.
17.
public
ChartViewModel()
18.
{
19.
this
.Data = GetDateTimeData(10);
20.
}
21.
22.
public
List<TemporalData> Data {
get
;
set
; }
23.
24.
public
string
Title {
get
;
set
; }
25.
public
static
List<TemporalData> GetDateTimeData(
int
itemsCount)
26.
{
27.
var startDate = DateTime.Now.AddYears(-1);
28.
29.
var items =
new
List<TemporalData>();
30.
for
(
int
i = 0; i < itemsCount; i++)
31.
{
32.
var data =
new
TemporalData();
33.
data.Category = startDate.AddDays(i);
34.
data.Value = random.Next(10, 30);
35.
36.
items.Add(data);
37.
}
38.
39.
return
items;
40.
}
41.
}
42.
public
class
ChartPage :
43.
ContentPage
44.
{
45.
public
ChartPage()
46.
{
47.
this
.BindingContext =
new
ChartViewModel() { Title=
"test"
};
48.
this
.BackgroundColor = Device.OnPlatform
49.
(
50.
Color.White, Color.White, Color.Transparent
51.
);
52.
var chart=CreateChart();
53.
chart.HeightRequest = 300;
54.
this
.Content = chart;
55.
}
56.
57.
private
static
RadCartesianChart CreateChart()
58.
{
59.
var chart =
new
RadCartesianChart
60.
{
61.
HorizontalAxis =
new
Telerik.XamarinForms.Chart.DateTimeContinuousAxis() {
62.
GapLength = 0.5,
63.
MajorStep=1,
64.
MajorStepUnit = TimeInterval.Day,
65.
LabelFitMode = AxisLabelFitMode.Rotate,
66.
ShowLabels =
true
67.
//PlotMode = AxisPlotMode.BetweenTicks
68.
},
69.
VerticalAxis =
new
Telerik.XamarinForms.Chart.NumericalAxis(),
70.
};
71.
72.
var series = CreateSeries();
73.
series.DisplayName =
"TEst"
;
74.
75.
chart.Series.Add(series);
76.
return
chart;
77.
}
78.
79.
private
static
AreaSeries CreateSeries()
80.
{
81.
var series =
new
Telerik.XamarinForms.Chart.AreaSeries();
82.
series.SetBinding(CategoricalSeries.ItemsSourceProperty,
new
Binding(
"Data"
));
83.
84.
series.ValueBinding =
new
Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
85.
{
86.
PropertyName =
"Value"
87.
};
88.
89.
series.CategoryBinding =
new
Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
90.
{
91.
PropertyName =
"Category"
92.
};
93.
94.
return
series;
95.
}
96.
}
97.
}