Click here to Skip to main content
15,947,411 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this code to draw kendo pie chart...and it's read data from json...the the title of the chart appear but the chart not appear

JavaScript
<div id="chart"></div>
 <script>
  
     function createChart() {
         $("#chart").kendoChart({
             dataSource: {
                 transport: {
                     read: {
                         dataType: "json",
                         url: "/home/getData"
                     }
                 }
             },
             title: {
                 text: "Break-up of Spain Electricity Production for 2008"
             },
             legend: {
                 position: "bottom"
             },
           

             series: [{
                 type: "pie",
                 field: "percentage",
                 categoryField: "source",
                 explodeField: "explode"
             }],
             seriesColors: ["#42a7ff", "#666666", "#999999", "#cccccc"],
             tooltip: {
                 visible: true,
                 template: "${ category } - ${ value }%"
             }
         });
     }

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


and this is the function which return the json

C#
public ActionResult getData()
       {
           var data = "[{ 'source': 'Hydro','percentage': 22,'explode': true},{'source':'Solar','percentage':2,'explode': false},{'source':'Nuclear','percentage': 49,'explode': false},{'source':'Wind','percentage': 27,'explode': false}]";
           //return data;


           return this.Content(data, "application/json");
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