can't plot data with categoryAxis type=Date

7 posts, 0 answers
  1. Olga
    Olga avatar
    13 posts
    Member since:
    May 2013

    Posted 29 May 2013 Link to this post

    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
  2. Hristo Germanov
    Admin
    Hristo Germanov avatar
    703 posts

    Posted 31 May 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Olga
    Olga avatar
    13 posts
    Member since:
    May 2013

    Posted 31 May 2013 Link to this post

    Yup, sorting does the trick!

    Is this requirement documented somewhere?
  5. T. Tsonev
    Admin
    T. Tsonev avatar
    2770 posts

    Posted 04 Jun 2013 Link to this post

    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!
  6. LW
    LW avatar
    1 posts
    Member since:
    Apr 2013

    Posted 06 Jun 2013 Link to this post

    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");
            }
  7. Hristo Germanov
    Admin
    Hristo Germanov avatar
    703 posts

    Posted 10 Jun 2013 Link to this post

    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!
  8. AppsWiz
    AppsWiz avatar
    15 posts
    Member since:
    Apr 2013

    Posted 20 Mar Link to this post

    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"

Back to Top
Kendo UI is VS 2017 Ready