2013-05-08 71 views
-1

我是剛剛接觸劍道的人,只是試用了它。我正在查看演示中提供的折線圖示例上的組綁定。我在演示中鏈接了遠程json,但無法讓圖表工作。如果我導航到json鏈接,json顯示正常。任何幫助將不勝感激。不能讓劍道自己的示例與遠程代碼一起工作

鏈接到演示:http://demos.kendoui.com/dataviz/line-charts/remote-data.html

鏈接到我的代碼:http://jsfiddle.net/Grjsn/3/

代碼文本:

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

<script> 
function createChart() { 
        $("#chart").kendoChart({ 
         dataSource: { 
          transport: { 
           read: { 
            url: "http://demos.kendoui.com/content/dataviz/js/spain-electricity.json", 
            dataType: "json" 
           } 
          }, 
          sort: { 
           field: "year", 
           dir: "asc" 
          } 
         }, 
         title: { 
          text: "Spain electricity production (GWh)" 
         }, 
         legend: { 
          position: "top" 
         }, 
         seriesDefaults: { 
          type: "line" 
         }, 
         series: 
         [{ 
          field: "nuclear", 
          name: "Nuclear" 
         }, { 
          field: "hydro", 
          name: "Hydro" 
         }, { 
          field: "wind", 
          name: "Wind" 
         }], 
         categoryAxis: { 
          field: "year", 
          labels: { 
           rotation: -90 
          } 
         }, 
         valueAxis: { 
          labels: { 
           format: "N0" 
          }, 
          majorUnit: 10000 
         }, 
         tooltip: { 
          visible: true, 
          format: "N0" 
         } 
        }); 
       } 

       $(document).ready(function() { 
        setTimeout(function() { 
         // Initialize the chart with a delay to make sure 
         // the initial animation is visible 
         createChart(); 

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

回答

相關問題