My Chart uses a rest API as datasource, here is sample response:
[{"us":5602,"them":6050,"Date":"2013-05-01T00:00:00"},
{"us":7192,"them":7120,"Date":"2013-04-01T00:00:00"},
{"us":6722,"them":7058,"Date":"2013-03-01T00:00:00"}]
I'm declaring lines chart with
categoryAxis: {
field: "Date",
type: "Date" ,
baseUnit: "month"
}
and I get empty chart.
If I comment out
categoryAxis: {
field: "Date"
/*,
type: "Date" ,
baseUnit: "month" */
}
then chart data is plotted (yaay!) but category axis looks really silly with lables like "2013-03-01T00:00:00"
What I'm missing here?
I've put sample here: http://jsbin.com/iqiqat/1/edit
Thanks a lot!
KendoUI ver: 2013.1.319
6 Answers, 1 is accepted
Thank you for contacting us.
The dates that you pass to the chart should be sorted. Could you try to sort your data by this "Date" field? Here is the example with your sample data: http://jsbin.com/odamet/6/edit
Hristo Germanov
Telerik
Is this requirement documented somewhere?
No, not really. We're working on a extended help topic regarding date series and we'll make sure to include this vital information there.
We actually used to accept the dates in any order (and sort them implicitly), but this turned out to be too slow.
Apologies for the caused inconvenience.
Tsvetomir Tsonev
Telerik
function createChart() {
$("#chart").kendoChart({
dataSource: {
transport: {
read: {
url: '/MeasureStat/HeatUnitConsume/HeatUnitConsumeOfBuildingReport/',
dataType: "json"
}
//, sort: {
// field: "CaptureDateString",
// dir: "asc"
//}
}
},
title: {
text: "Spain electricity production (GWh)"
},
legend: {
position: "top"
},
seriesDefaults: {
type: "line"
},
series:
[{
field: "HeatUnitConsumeValue",
name: "Nuclear"
}],
categoryAxis: {
field: "CaptureDateString",
type: "date",
//baseUnit: "weeks",
},
valueAxis: {
labels: {
format: "N2"
},
majorUnit: 0.1
},
tooltip: {
visible: true,
format: "N2"
}
}).data("kendoChart");
}
Could you give me a piece of your json data that you pass to the chart?
Regards,Hristo Germanov
Telerik
For IE11 (and probably all versions of IE, you need to make sure that the json dates that your chart is receiving are in UTC format or you'll get this error. My JSON is generated using C# on the server, so I need to format a date like this before returning it as JSON:
DateTime.Now.ToUniversalTime().ToString("o"