我正在嘗試將資料系結到甜甜圈劍道組件。到目前為止,我的作業在下面
js檔案:-
function createChart() {
$("#chart").kendoChart({
dataSource: {
transport: {
read: {
url: "/ert.mvc/Summary?id=23",
dataType: "json",
type: "GET"
}
}
},
title: {
position: "bottom",
text: "Share of Internet Population Growth"
},
legend: {
visible: false
},
series: [{
data: [{
type: "donut",
field: "newlyRequested",
categoryField: "source",
explodeField: "explode" },
{
type: "donut",
field: "pending",
categoryField: "source",
explodeField: "explode"
}]
}],
seriesColors: ["#42a7ff", "#666666"],
tooltip: {
visible: true,
template: "#= category # (#= series.name #): #= value #%"
}
});
}
我的 api 回應如下:-
{
total: 120,
pending: 25,
incomplete: 10,
newlyRequested: 10
}
我按照https://demos.telerik.com/kendo-ui/donut-charts/donut-labels示例進行操作。但我得到 kendo.all.js:7786 Uncaught TypeError: e.slice is not a function error 。我的預期結果是我想顯示未完成的甜甜圈圖,不完整......占總數的百分比。
請有任何想法
uj5u.com熱心網友回復:
首先,您的 API 回應是錯誤的。它應該是一個像這樣的物件陣列:
[
{type: "total", value: 120},
{type: "pending", value: 25},
{type: "incomplete", value: 10},
{type: "newlyRequested", value: 10}
]
根據上述 API 回應,您必須更改series配置。最后,您的圓環圖配置應如下所示:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Kendo UI Snippet</title>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2021.3.914/styles/kendo.default-v2.min.css"/>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2021.3.914/js/kendo.all.min.js"></script>
</head>
<body>
<div id="chart"></div>
<script>
$("#chart").kendoChart({
dataSource: [
{type: "total", value: 120},
{type: "pending", value: 25},
{type: "incomplete", value: 10},
{type: "newlyRequested", value: 10}
],
title: {
position: "bottom",
text: "Share of Internet Population Growth"
},
legend: {
visible: false
},
series: [{
type: "donut",
field: "value",
categoryField: "type",
}],
seriesColors: ["#42a7ff", "#666666"],
tooltip: {
visible: true,
template: "#= category # (#= kendo.format('{0:P}', percentage) #): #= value #"
},
seriesDefaults: {
labels: {
template: "#= category # - #= kendo.format('{0:P}', percentage)#",
position: "outsideEnd",
visible: true,
background: "transparent"
}
},
});
</script>
</body>
</html>
我添加了一個系列標簽并修改了工具提示以使圖表看起來更好。您可能想在此處查看更多圖表示例。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/314701.html
標籤:查询 阿贾克斯 剑道 剑道格子 剑道-asp.net-mvc
上一篇:根據回應的國家設定不同的價格
下一篇:顯示/隱藏密碼ASP.NET
