我想做一个甜甜圈图表,每个弧形都有一个特定格式的字符串.ChartJSImage中的选项有限,我想知道这是否可能.更清楚地说,第一张照片是我得到的,第二张照片是我想要的.
这个问题看起来很简单,但我觉得ChartJSImage非常有限,我找不到解决方案.以下是我try 过的代码
const line_chart = ChartJSImage().chart({
"type": "doughnut",
"data": {
labels: [
'Carbs',
'Protien',
'Fats'
],
options: {
plugins: {
legend: { // i assumed that I had to put the legend key? still did not work.
display: true,
position: 'top',
align: 'center'
}
}
},
datasets: [{
label: 'Calorie Intake',
data: [300, 50, 100], // I want to use each number in the array and then 'cal'
backgroundColor: [
'rgb(255, 99, 132)',
'rgb(54, 162, 235)',
'rgb(255, 205, 86)'
]
}],
}}) // Line chart
.backgroundColor('white')
.width(500) // 500px
.height(300); // 300px
line_chart.toFile('myimg.png')
如果甚至可以使用ChartJSImage将标签添加到甜甜圈,那么请告诉我如何操作.
提前谢谢你