Hello,
I have 3 chart series on my page, bar, line, and scatterpoint.
I successfully make the bar to be coloured (5 colours) as i programmed. But there is no PaletteMode property on LineSeries and ScatterPointSeries.
Why and How the code should be?
Here is my code,
this code only make the line and scatterpoint series 1 color, while my _viewmodel.CustomPalette has actually 5 colours (with 5 items).
01.
void
setChartData()
02.
{
03.
chartView.Children.Clear();
04.
05.
06.
string
itemSource =
"_SummaryList"
;
07.
string
categoryBinding =
"Short_Name"
;
08.
string
valueBinding = _viewmodel.ChartValue;
09.
10.
var hAxis =
new
CategoricalAxis();
11.
hAxis.LabelFontSize = 6;
12.
13.
var vAxis =
new
NumericalAxis();
14.
vAxis.LabelFontSize = 7;
15.
vAxis.LabelFormat =
"#,#.#"
;
16.
17.
var chart =
new
RadCartesianChart
18.
{
19.
HorizontalAxis = hAxis,
20.
VerticalAxis = vAxis,
21.
VerticalOptions = LayoutOptions.FillAndExpand,
22.
HorizontalOptions = LayoutOptions.FillAndExpand
23.
};
24.
25.
switch
(_viewmodel.ChartType)
26.
{
27.
case
"Bar"
:
28.
var bar =
new
BarSeries();
29.
bar.SetBinding(ChartSeries.ItemsSourceProperty,
new
Binding(itemSource));
30.
bar.ValueBinding =
new
PropertyNameDataPointBinding(valueBinding);
31.
bar.CategoryBinding =
new
PropertyNameDataPointBinding(categoryBinding);
32.
bar.PaletteMode = SeriesPaletteMode.DataPoint;
33.
bar.ShowLabels =
true
;
34.
chart.Series.Add(bar);
35.
chart.Palette = _viewmodel.CustomPalette;
36.
break
;
37.
case
"Line"
:
38.
var lines =
new
LineSeries();
39.
lines.SetBinding(ChartSeries.ItemsSourceProperty,
new
Binding(itemSource));
40.
lines.ValueBinding =
new
PropertyNameDataPointBinding(valueBinding);
41.
lines.CategoryBinding =
new
PropertyNameDataPointBinding(categoryBinding);
42.
lines.ShowLabels =
true
;
43.
chart.Series.Add(lines);
44.
chart.Palette = _viewmodel.CustomPalette;
45.
break
;
46.
case
"Point"
:
47.
var point =
new
ScatterPointSeries();
48.
point.SetBinding(ChartSeries.ItemsSourceProperty,
new
Binding(itemSource));
49.
point.YValueBinding =
new
PropertyNameDataPointBinding(valueBinding);
50.
point.XValueBinding =
new
PropertyNameDataPointBinding(categoryBinding);
51.
point.ShowLabels =
true
;
52.
chart.Series.Add(point);
53.
chart.Palette = _viewmodel.CustomPalette;
54.
break
;
55.
}
56.
57.
chartView.Children.Add(chart);
58.
}