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

标签 html angular typescript chart.js

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

显示方式:

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/

相关文章:

Angular :ngc 还是 tsc?

angular - 在具有按钮的标题上设置条件(禁用/显示按钮)[Angular]

typescript - 如何让 VSCode 加载 NPM 依赖项的源映射?

javascript - 错误错误 : Uncaught (in promise): TypeError: Cannot set property 'devices' of undefined in ionic 4 Angular

javascript - 很酷的网页风格,用最少的努力

html - 未加载特定文件夹名称的 CSS 文件

angular - 填充数组并使用 Angular Material 使其可过滤

javascript - 以特定格式将 mysql 数据检索到 javascript 时出现问题

javascript - 上传前可以在 html 表单上调整图像(客户端)的大小吗?

TypeScript 在静态实现中推断出更通用的类型