Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Here is my code but it does not work... shows nothing :|
what have i done wrong?
how to call the datasource in the function?

<div id="example" class="k-content absConf">
            <div class="chart-wrapper" style="margin: auto;">
                <div id="chart"></div>
            </div>
            <script type="text/javascript">

                var transport = {
                    read: {
                        url: "..."
                    }
                };

                var data = new kendo.data.DataSource({
                    transport: transport,
                    sort: {
                        field: "day",
                        dir: "asc"
                    }
                });
                
               
             



 function createChart() {

     $("#chart").kendoChart({
         theme: $(document).data("kendoSkin") || "silver",
         dataSource: data,
             
         

         title: {
             text: "Value per day"
         },
         legend: {
             position: "top",
             font: "18px Verdana"

         },
         seriesDefaults: {
             type: "line"
         },
         series:
                        [{
                            field: "value",
                            name: "value"
                        }],

         valueAxis: {
             field: "value"
         },
         categoryAxis: {
             field: "day"
         },


         tooltip: {
             visible: true,
             format: "N0"
         }
     });
                 }

                 $(document).ready(function () {
                     setTimeout(function () {


                         createChart();

                         $("#example").bind("kendo:skinChange", function (e) {
                             createChart();
                             data.read();
                         });
                     }, 400);
                 });
                        
            </script>
        </div>


and the result from the webservice :

CSS
{ "day": "Monday", "value": 10 }, { "day": "Tuesday", "value": 18 }, { "day": "Wednesday", "value": 43 } ;
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900