This is a migrated thread and some comments may be shown as answers.

can't plot data with categoryAxis type=Date

6 Answers 127 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Olga
Top achievements
Rank 1
Olga asked on 29 May 2013, 07:03 AM
Hello!

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

Sort by
0
Hristo Germanov
Telerik team
answered on 31 May 2013, 07:07 AM
Hi Olga,

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

Regards,
Hristo Germanov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Olga
Top achievements
Rank 1
answered on 31 May 2013, 04:44 PM
Yup, sorting does the trick!

Is this requirement documented somewhere?
0
T. Tsonev
Telerik team
answered on 04 Jun 2013, 10:57 AM
Hi,

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.

Regards,
Tsvetomir Tsonev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
LW
Top achievements
Rank 1
answered on 06 Jun 2013, 09:38 AM
i also have question, But my chart datasource is binding remote data ,my js is
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");
        }
0
Hristo Germanov
Telerik team
answered on 10 Jun 2013, 07:24 AM
Hello LW,

Could you give me a piece of your json data that you pass to the chart?

Regards,
Hristo Germanov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
AppsWiz
Top achievements
Rank 1
answered on 21 Mar 2016, 12:11 AM

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"

Tags
Charts
Asked by
Olga
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Olga
Top achievements
Rank 1
T. Tsonev
Telerik team
LW
Top achievements
Rank 1
AppsWiz
Top achievements
Rank 1
Share this question
or