我一直在使用ChartJS与PrimeNG,在Angular 。需要做一个圆环图,我相信一个数据集。我需要使它每个值有不同的厚度,像这样
到目前为止,我已经尝试了很多方法,并阅读了很多关于圆环图的ChartJS文档,但没有一个选项对我有帮助。
下面是如何在HTML中实现图表
<p-chart type="doughnut" [data]="donutData" [options]="donutChartOptions" class="h-10 my-4"></p-chart>
下面是.ts
this.donutData = {
labels: ['A', 'B', 'C'],
datasets: [
{
data: [300, 50, 100],
backgroundColor: ['#F36F56', '#FFC300', '#B8A3FF'],
hoverBackgroundColor: ['#F36F56', '#FFC300', '#B8A3FF'],
},
],
};
this.donutChartOptions = {
cutout: 50,
plugins: {
legend: {
display: false,
labels: {
color: '#ebedef',
},
},
},
};
1条答案
按热度按时间zzlelutf1#
Here you can find the answer of your question: https://github.com/chartjs/Chart.js/issues/6195
I transferred the answer of "ex47" to chart.js 3 I put the constant "data" into the html file just to have less double code, it should better be in the javascript file.
myChart.js
"Spirit04eK"'s solution sets the thickness in descending order of the magnitude of the value
myChart.js