Binding 无法获取剑道自己的示例以使用远程代码
我是剑道新手,只是尝试一下而已。我正在演示中提供的折线图示例上查看组绑定。我在演示中链接了远程json,但无法使图表正常工作。如果我导航到json链接,json显示良好。任何帮助都将不胜感激 链接到演示: 链接到我的代码: 代码文本:Binding 无法获取剑道自己的示例以使用远程代码,binding,charts,kendo-ui,Binding,Charts,Kendo Ui,我是剑道新手,只是尝试一下而已。我正在演示中提供的折线图示例上查看组绑定。我在演示中链接了远程json,但无法使图表正常工作。如果我导航到json链接,json显示良好。任何帮助都将不胜感激 链接到演示: 链接到我的代码: 代码文本: <div id="example" class="k-content absConf"> <div class="chart-wrapper" style="margin: auto;"> <div id="ch
<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>
函数createChart(){
$(“#图表”)。肯多卡特({
数据源:{
运输:{
阅读:{
url:“http://demos.kendoui.com/content/dataviz/js/spain-electricity.json",
数据类型:“json”
}
},
排序:{
字段:“年”,
主管:“asc”
}
},
标题:{
文本:“西班牙电力生产(GWh)”
},
图例:{
位置:“顶部”
},
系列默认值:{
类型:“行”
},
系列:
[{
字段:“核”,
名称:“核能”
}, {
字段:“hydro”,
名称:“水电”
}, {
场:“风”,
名称:“风”
}],
类别:{
字段:“年”,
标签:{
轮换:-90
}
},
valueAxis:{
标签:{
格式:“N0”
},
主要单位:10000
},
工具提示:{
可见:对,
格式:“N0”
}
});
}
$(文档).ready(函数(){
setTimeout(函数(){
//延迟初始化图表以确保
//初始动画可见
createChart();
$(“#示例”).bind(“剑道:皮肤变化”,函数(e){
createChart();
});
}, 400);
});
加载JSON会抛出错误:
无法加载XMLHttpRequest。访问控制不允许原点允许原点
这是由于浏览器中AJAX请求的同源安全性造成的