gpt4 book ai didi

html - ChartJS "half donut"图表显示不正确

转载 作者:行者123 更新时间:2023-12-04 07:20:51 25 4
gpt4 key购买 nike

我的图表显示不正确,下面是它的显示方式和假定的显示方式:

显示方式:

enter image description here

它的样子:

enter image description here

我的html代码:

<div style="display:block; width: 400px; height: 400px">
<canvas id="dashboardChart" width="400" height="400"></canvas>
</div>

我的 typescript 组件代码:

var data = {
datasets: [{
data: [10, 20, 30]
}],
labels: [
'Red',
'Yellow',
'Blue'
]
};

var ctx = document.getElementById("dashboardChart") as HTMLCanvasElement;
var myDoughnutChart = new Chart(ctx, {
type: 'doughnut',
data: data,
options: {
rotation: 1 * Math.PI,
circumference: 1 * Math.PI
}
});

如果有人能提供帮助,将不胜感激。

最佳答案

Doughnut rotation option is now in degrees

试试这些改变:

circumference: 180,
rotation: -90,

迁移 docs

关于html - ChartJS "half donut"图表显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68512787/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com