Kendo UI 图表数据绑定未触发
Kendo UI Chart DataBinding not firing
我正在考虑在数据源绑定后查看有多少项目。出于某种原因,我什至无法触发 dataBound 或 dataBinding 事件。
数据实际上被传递到一个函数中,因此在创建网格时它在本地具有数据。
示例:http://dojo.telerik.com/IjAKo/2
源代码:
<div id="grid"></div>
<script>
function onDataBinding(e) {
console.log('here');
}
$(document).ready(function() {
var chart = $("#grid").kendoChart({
chartArea: {
height: 250,
},
legend: {
position: "bottom",
labels: {
font: "bold 10px Arial",
}
},
seriesDefaults: {
type: "column",
spacing: 0,
overlay: {
gradient: "none"
}
},
series: [{
name: "ESCROW",
color: "#cccbcb",
data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
}, {
name: "NON-ESCROW",
color: "#406f8c",
data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
}],
categoryAxis: {
line: {
visible: false
},
categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Set", "Oct", "Nov", "Dec"],
majorGridLines: {
visible: false
}
},
valueAxis: {
labels: {
format: "{0:N0}"
},
line: {
visible: false
},
majorGridLines: {
visible: false
},
max: 20
},
tooltip: {
visible: true,
format: "{0:N0}"
},
dataBinding: onDataBinding // tried to do it here.
});
// tried to bind after initialization
chart.bind("dataBound", function(e) {
alert('here')
});
});
</script>
图表中没有dataBinding
事件,只有dataBound
。此事件仅在图表指定 dataSource
时触发,即使是空的,因此您必须在图表中添加如下行:
dataSource: {},
还有一件事:在您的示例中您使用本地数据,因此如果您首先创建图表然后将函数绑定到 dataBound
,事件将不会触发,因为数据已经绑定。在图表构造函数中定义 dataBound 事件:
dataBound: function(e) { console.log('data bound') },
我正在考虑在数据源绑定后查看有多少项目。出于某种原因,我什至无法触发 dataBound 或 dataBinding 事件。
数据实际上被传递到一个函数中,因此在创建网格时它在本地具有数据。
示例:http://dojo.telerik.com/IjAKo/2
源代码:
<div id="grid"></div>
<script>
function onDataBinding(e) {
console.log('here');
}
$(document).ready(function() {
var chart = $("#grid").kendoChart({
chartArea: {
height: 250,
},
legend: {
position: "bottom",
labels: {
font: "bold 10px Arial",
}
},
seriesDefaults: {
type: "column",
spacing: 0,
overlay: {
gradient: "none"
}
},
series: [{
name: "ESCROW",
color: "#cccbcb",
data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
}, {
name: "NON-ESCROW",
color: "#406f8c",
data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
}],
categoryAxis: {
line: {
visible: false
},
categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Set", "Oct", "Nov", "Dec"],
majorGridLines: {
visible: false
}
},
valueAxis: {
labels: {
format: "{0:N0}"
},
line: {
visible: false
},
majorGridLines: {
visible: false
},
max: 20
},
tooltip: {
visible: true,
format: "{0:N0}"
},
dataBinding: onDataBinding // tried to do it here.
});
// tried to bind after initialization
chart.bind("dataBound", function(e) {
alert('here')
});
});
</script>
图表中没有dataBinding
事件,只有dataBound
。此事件仅在图表指定 dataSource
时触发,即使是空的,因此您必须在图表中添加如下行:
dataSource: {},
还有一件事:在您的示例中您使用本地数据,因此如果您首先创建图表然后将函数绑定到 dataBound
,事件将不会触发,因为数据已经绑定。在图表构造函数中定义 dataBound 事件:
dataBound: function(e) { console.log('data bound') },