I would like to combine a stacked bar and line chart in the same graph. I am able to generate the stacked bars, however, I am having difficulties generating the line graph. The data for the chart is fed from the Model. Any help is appreciated.
Here is the "View"
01.
@(Html.Kendo().Chart<MyModelName>()
02.
.Name(
"MyChartName"
)
03.
.AutoBind(
true
)
04.
.Legend(legend => legend
05.
.Visible(
true
)
06.
)
07.
.DataSource(ds => ds
08.
.Read(read => read.Action(
"MyAction"
,
"MyController"
))
09.
.Group(group => group.Add(model => model.Country))
10.
)
11.
.SeriesDefaults(seriesDefaults =>
12.
seriesDefaults.Column().Stack(
true
)
13.
)
14.
.Series(series =>
15.
{
16.
series
17.
.Column(model => model.ValueAmount)
18.
.CategoryField(
"ValueYearMonth"
)
19.
.Labels(labels => labels
20.
.Visible(
true
)
21.
.Background(
"transparent"
).Visible(
true
)
22.
.Position(ChartBarLabelsPosition.OutsideEnd))
23.
;
24.
series
25.
.Line(model => <!!! NOT SURE HERE !!!>) //model.ValueAmount does not work
26.
//.Line (new int[] { 35, 25, 50, -10, 15, 5, 35 }) //
27.
.Color(
"#ff1c1c"
);
28.
29.
})
30.
.CategoryAxis(axis => axis
31.
.Labels(label => label
32.
.Position(ChartAxisLabelsPosition.Start)
33.
)
34.
.MajorGridLines(lines => lines.Visible(
true
))
35.
.Line(line => line.Visible(
false
))
36.
.Visible(
true
)
37.
)
38.
.ValueAxis(axis => axis.Numeric()
39.
.MajorGridLines(lines => lines.Visible(
false
))
40.
.Visible(
true
)
41.
)
42.
.Tooltip(tooltip => tooltip
43.
.Visible(
true
)
44.
)
45.
.Events(events => events
46.
.DataBound(
"onDataBoundStackedChart"
)
47.
)
48.
)
The Model:
01.
public
class
MyModel
02.
{
03.
public
string
Country {
get
;
set
; }
04.
public
decimal
ValueAmount {
get
;
set
; }
05.
public
string
Color {
get
;
set
; }
06.
public
DateTime ValueDate {
get
;
set
; }
07.
public
int
ValueYearMonth {
get
;
set
; }
08.
public
decimal
GlobalValueAmountByMonth {
get
;
set
; }
09.
}
And the Controller reads the data into the Model and "return Json(result);"
Thanks in advance,
Ricky