"TypeError: a[0] is undefined" when binding to remote JSON data

2 posts, 0 answers
  1. Chris
    Chris avatar
    1 posts
    Member since:
    Aug 2010

    Posted 22 Jul 2013 Link to this post

    Trying to populate a dataviz chart with remote data but no data is plotted and "TypeError: a[0] is undefined" is thrown by kendo.dataviz.min.js.

    chart is setup as follows:

    function createChart(Description) {
                var chartds = new kendo.data.DataSource({
                    transport: {
                        read: {
                            type: "POST",
                            url: "../AJAX/service.asmx/GetMetricTrend",
                            dataType: "json",
                            contentType: "application/json"
                        },
                        parameterMap: function (data, operation) {
                            if (operation != "read") {
                                // web service method parameters need to be send as JSON. The Create, Update and Destroy methods have a "products" parameter.
                                //return JSON.stringify(data);

                            }
                            else {
                                // web services need default values for every parameter
                                data = $.extend({ intMetricID: 17}, data);

                                return JSON.stringify(data);
                            }
                        }
                    },
                    schema: {
                        data: "d"
                    }
                });

                $("#chart").kendoChart({
                    dataSource: chartds,
                    title: {
                        text: Description + " Weekly Trend"  
                    },
                    legend: {
                        position: "bottom"
                    },
                    seriesDefaults: {
                        type: "line"
                    },
                    series:
                    [{
                        field: "Value",
                        name: "Actual Value"
                    }],
                    categoryAxis: {
                        field: "Week",
                        labels: {
                            rotation: 0
                        }
                    },
                    valueAxis: {
                        labels: {
                            format: "N0"
                        },
                        majorUnit: 10
                    },
                    tooltip: {
                        visible: true,
                        format: "N0"
                    }
                });
            }


    JSON response:

    {"d":[{"__type":"clsMetricTrendValues","Week":5,"Value":104.00},{"__type":"clsMetricTrendValues","Week":6,"Value":109.00},{"__type":"clsMetricTrendValues","Week":7,"Value":94.00},{"__type":"clsMetricTrendValues","Week":9,"Value":96.00},{"__type":"clsMetricTrendValues","Week":10,"Value":90.00},{"__type":"clsMetricTrendValues","Week":12,"Value":86.00},{"__type":"clsMetricTrendValues","Week":13,"Value":90.00},{"__type":"clsMetricTrendValues","Week":14,"Value":95.00},{"__type":"clsMetricTrendValues","Week":15,"Value":98.00}]}


    following .js files are included:

    jquery-1.8.2.min.js
    jquery-ui-1.9.2.custom.min.js
    kendo.dataviz.min.js
    kendo.web.min.js

    Thanks
  2. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2622 posts

    Posted 23 Jul 2013 Link to this post

    Hi Chris,

    I have already answered to the same question in your other thread, however I am pasting my reply here too:

    The provided Chart's configuration looks OK, however I checked the details in your other thread and believe the issue is caused by kendo.dataviz.min.js is included before kendo.web.min.js (while the order should be opposite). Keep in mind when using widgets from different Kendo UI suites it is recommended using the combined kendo.all.min.js file (which contains a minified version of all scripts). Also the used Kendo UI version (v2013.1.514) requires jQuery 1.9.1 while you are using 1.8.2. More detailed information  on this subject can be found in the corresponding documentation.

    Regards,
    Iliana Nikolova
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top