使用kendoChart显示数据
我想知道为什么我无法使用 kendoChart 显示结果查询。当我尝试这个时
series: [{
type: "pie",
data: [{
category: "Available",
value: 24
}]
}],
它有效!
但是当我尝试输入查询结果时(请参见下图),
series: [{
type: "pie",
data: [{
category: status,
value: counts
}]
}],
没有记录显示
我当前的代码:
<script>
const createChart = async () =>{
const { status, counts } = await getConditions();
console.log(status, counts)
$("#chart1").kendoChart({
title: {
text: "All Books"
},
legend: {
position: "top"
},
seriesDefaults: {
labels: {
template: "#= category # - #= kendo.format('{0:P}', percentage)#",
position: "outsideEnd",
visible: true,
background: "transparent"
}
},
series: [{
type: "pie",
data: [{
category: status,
value: counts
}]
}],
tooltip: {
visible: true,
template: "#= category # - #= kendo.format('{0:P}', percentage) #"
}
});
}
$(document).ready(()=>{
createChart();
});
</script>
console.log(status, counts) 中的结果数据
I wonder why I cant display my result query using the kendoChart. when i tried this
series: [{
type: "pie",
data: [{
category: "Available",
value: 24
}]
}],
It works!
but when i tried to put the result of my query (please see the picture below)
series: [{
type: "pie",
data: [{
category: status,
value: counts
}]
}],
no record display
my current code:
<script>
const createChart = async () =>{
const { status, counts } = await getConditions();
console.log(status, counts)
$("#chart1").kendoChart({
title: {
text: "All Books"
},
legend: {
position: "top"
},
seriesDefaults: {
labels: {
template: "#= category # - #= kendo.format('{0:P}', percentage)#",
position: "outsideEnd",
visible: true,
background: "transparent"
}
},
series: [{
type: "pie",
data: [{
category: status,
value: counts
}]
}],
tooltip: {
visible: true,
template: "#= category # - #= kendo.format('{0:P}', percentage) #"
}
});
}
$(document).ready(()=>{
createChart();
});
</script>
the results data from the console.log(status, counts)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于
status
和counts
是数组,因此您需要将其转换为对象数组(带有category
和value fields) Kendo 可以理解。请参阅下面的示例并在 Telerik DOJO 中尝试。
As
status
andcounts
are arrays, you'll need to convert it to an array of objects (withcategory
andvalue
fields) Kendo can understand. See example below and try it in the Telerik DOJO.