Ok... frustratingly this is the second time I'm writing this as the first post failed for some reason.
I know there is a similar post to this here, http://www.telerik.com/forums/stacked-column-chart-where-group-is-a-property but the example code looks nothing like the api documentation, so hopefully someone can explain what's wrong with mine. The grouping is missing the first day completely!
Json looks like:
[{"tdate": "2014-03-18T00:00:00", "data": 652.48 , "CatName": "Starters"},{"tdate": "2014-03-18T00:00:00", "data": 1245.87 , "CatName": "Spirits"},{"tdate": "2014-03-21T00:00:00", "data": 326.55 , "CatName": "Beers"},{"tdate": "2014-03-22T00:00:00", "data": 124.28 , "CatName": "Beers"},{"tdate": "2014-03-24T00:00:00", "data": 785.24 , "CatName": "Starters"},{"tdate": "2014-03-24T00:00:00", "data": 444.74 , "CatName": "Beers"},{"tdate": "2014-03-24T00:00:00", "data": 345.54 , "CatName": "Spirits"}]
HTML
<div id="chart"></div>
Script:
var myTheme = 'metro';
var myds = $('#MainContent_hdn1').val();
var jsondata = $.parseJSON(myds);
var mydatasource = new kendo.data.DataSource({
group: [
{ field: "CatName" }
],
sort: { field: "tdate", dir: "asc" },
data: jsondata
});
$("#chart").kendoChart({
dataSource: mydatasource,
series: [{
field: "data"
}],
group: { field: "CatName" },
categoryAxis: {
field: "tdate",
baseUnit: 'day',
type: 'date',
majorGridLines: {
visible: false
},
line: {
visible: false
}
},
seriesDefaults: {
stack: true
},
chartArea: {
height: 250
},
theme: myTheme,
tooltip: {
visible: true,
template: "#= series.name #: #= value #"
}
});
Output looks like attached pic.
I know there is a similar post to this here, http://www.telerik.com/forums/stacked-column-chart-where-group-is-a-property but the example code looks nothing like the api documentation, so hopefully someone can explain what's wrong with mine. The grouping is missing the first day completely!
Json looks like:
[{"tdate": "2014-03-18T00:00:00", "data": 652.48 , "CatName": "Starters"},{"tdate": "2014-03-18T00:00:00", "data": 1245.87 , "CatName": "Spirits"},{"tdate": "2014-03-21T00:00:00", "data": 326.55 , "CatName": "Beers"},{"tdate": "2014-03-22T00:00:00", "data": 124.28 , "CatName": "Beers"},{"tdate": "2014-03-24T00:00:00", "data": 785.24 , "CatName": "Starters"},{"tdate": "2014-03-24T00:00:00", "data": 444.74 , "CatName": "Beers"},{"tdate": "2014-03-24T00:00:00", "data": 345.54 , "CatName": "Spirits"}]
HTML
<div id="chart"></div>
Script:
var myTheme = 'metro';
var myds = $('#MainContent_hdn1').val();
var jsondata = $.parseJSON(myds);
var mydatasource = new kendo.data.DataSource({
group: [
{ field: "CatName" }
],
sort: { field: "tdate", dir: "asc" },
data: jsondata
});
$("#chart").kendoChart({
dataSource: mydatasource,
series: [{
field: "data"
}],
group: { field: "CatName" },
categoryAxis: {
field: "tdate",
baseUnit: 'day',
type: 'date',
majorGridLines: {
visible: false
},
line: {
visible: false
}
},
seriesDefaults: {
stack: true
},
chartArea: {
height: 250
},
theme: myTheme,
tooltip: {
visible: true,
template: "#= series.name #: #= value #"
}
});
Output looks like attached pic.