我是剑道的新手,只是在试用它。我正在查看演示中提供的折线图示例上的组绑定。我在演示中链接了远程 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>