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

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

1 Answer 275 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 22 Jul 2013, 04:12 PM
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

1 Answer, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 23 Jul 2013, 11:52 AM
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!
Tags
Charts
Asked by
Chris
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Share this question
or