Hi,
We're just evaluating Kendo UI chart controls, and have a question about Stacked Column Charts.
When generating a stacked column chart do all records in the datasource have to have the same number of values?
For example:
If I have a chart as follows:
and the data is as follows:
The chart is rendered as I expect, with 3 columns, each with a stack containing "Stack A", "Stack B" and "Stack C". However, if I remove the "Stack C / Category:2" record, the value of "Stack C / Category:3" record appears on the 2nd column, eg:
Other behaviour also occurs if the first "group" doesn't contain all the possible categories, eg you can end up with columns that don't have a label.
Is there a way to have the chart use 0 as the value for the missing records, or is there another way to achieve this.
We're just evaluating Kendo UI chart controls, and have a question about Stacked Column Charts.
When generating a stacked column chart do all records in the datasource have to have the same number of values?
For example:
If I have a chart as follows:
$(
"#chart"
).kendoChart
(
{
dataSource: { data: arData, sort: [{ field:
"axisOrder"
, dir:
"asc"
}, { field:
"stack"
, dir:
"asc"
}], group: [{ field:
"stack"
}] },
legend: { visible:
false
},
series: [{
stack:
true
,
type:
"column"
,
field:
"value"
}],
categoryAxis: {
field:
"category"
,
labels: {
rotation: -90
}
}
}
)
and the data is as follows:
var
arData = [
{ stack:
"Stack A"
, category:
"1"
, value: 10, axisOrder: 1 },
{ stack:
"Stack A"
, category:
"2"
, value: 20, axisOrder: 2 },
{ stack:
"Stack A"
, category:
"3"
, value: 30, axisOrder: 3 },
{ stack:
"Stack B"
, category:
"1"
, value: 20, axisOrder: 1 },
{ stack:
"Stack B"
, category:
"2"
, value: 30, axisOrder: 2 },
{ stack:
"Stack B"
, category:
"3"
, value: 40, axisOrder: 3 },
{ stack:
"Stack C"
, category:
"1"
, value: 30, axisOrder: 1 },
{ stack:
"Stack C"
, category:
"2"
, value: 40, axisOrder: 2 },
{ stack:
"Stack C"
, category:
"3"
, value: 50, axisOrder: 3}
];
The chart is rendered as I expect, with 3 columns, each with a stack containing "Stack A", "Stack B" and "Stack C". However, if I remove the "Stack C / Category:2" record, the value of "Stack C / Category:3" record appears on the 2nd column, eg:
var
arData = [
{ stack:
"Stack A"
, category:
"1"
, value: 10, axisOrder: 1 },
{ stack:
"Stack A"
, category:
"2"
, value: 20, axisOrder: 2 },
{ stack:
"Stack A"
, category:
"3"
, value: 30, axisOrder: 3 },
{ stack:
"Stack B"
, category:
"1"
, value: 20, axisOrder: 1 },
{ stack:
"Stack B"
, category:
"2"
, value: 30, axisOrder: 2 },
{ stack:
"Stack B"
, category:
"3"
, value: 40, axisOrder: 3 },
{ stack:
"Stack C"
, category:
"1"
, value: 30, axisOrder: 1 },
//{ stack: "Stack C", category: "2", value: 40, axisOrder: 2 },
{ stack:
"Stack C"
, category:
"3"
, value: 50, axisOrder: 3}
];
Other behaviour also occurs if the first "group" doesn't contain all the possible categories, eg you can end up with columns that don't have a label.
Is there a way to have the chart use 0 as the value for the missing records, or is there another way to achieve this.