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

Kendo chart does not read datasource

3 Answers 123 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Paolo
Top achievements
Rank 1
Paolo asked on 23 Nov 2015, 10:40 AM

I have this code for diaplaying a pia chart, largely taken from telerik examples:

 <div id="chart100Month" style="width:100%"></div>

 

<script type="text/javascript">
function createChartMonth100() {
    //console.log('createChartMonth100');
    $("#chart100month").kendoChart({

        dataSource: {
            transport: {
                read: {
                    url: "/getchartdatabytesttype100",
                    dataType: "json"
                }
            },
            filter: {
               // field: "year", operator: "eq", value: year
            },
            sort: {
//                field: "year",
//                dir: "asc"
            }
        },
        title: {
            text: "test"
        },
        legend: {
            position: "top"
        },
        seriesDefaults: {
            type: "pie"
        },
        series: [{
                type: "pie",
                    field: "percentage",
                    categoryField: "type",}],
        tooltip: {
            visible: true,
            format: "N0",
            // template: "#= category # - #= kendo.format('{0:P}', percentage)#"
        }
    });
}

$(document).ready(createChartMonth100);
$(document).bind("kendo:skinChange", createChartMonth100);
</script>

the url getchartdatabytesttype100 gives back a json array:

[{"percentage":0,"type":"hypo"},{"percentage":66.666666666667,"type":"normal"},{"percentage":16.666666666667,"type":"lighthyper"},"percentage":16.666666666667,"type":"hyper"}

But the problem is that firebug console showd the datasource is not read.

No calls to getchartdatabytesttype100 are made and the chart (even an empty) is not created, but I'm sure kendoChart function is called.

Do you have any suggestions about it?

Thanks

Paolo

3 Answers, 1 is accepted

Sort by
0
Paolo
Top achievements
Rank 1
answered on 23 Nov 2015, 12:26 PM
Sorry, it was just a typo chart100month
0
Helen
Telerik team
answered on 24 Nov 2015, 03:57 PM
Hi Paolo,

Did you manage to solve the problem?
If not, could you replicate it in a dojo,so we to investigate it locally?

Regards,
Helen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Paolo
Top achievements
Rank 1
answered on 24 Nov 2015, 04:30 PM

Hi Helen, yes, this problem is solved.

As you can see in my code upon there is a typo error in the id of the div where the chart sould be created. The chart div element is:

<div id="chart100Month" style="width:100%"></div>

 While the target kendoChart function div was chart100month:

function createChartMonth100() {
        $("#chart100month").kendoChart({

 

 As you can see the mistake is mine and obvious.

Thanks for your availability.

Paolo

Tags
Charts
Asked by
Paolo
Top achievements
Rank 1
Answers by
Paolo
Top achievements
Rank 1
Helen
Telerik team
Share this question
or