我在chart.js中创建了一个饼图,但不知道如何更改每个饼图切片中计数的字体颜色。
const options = {
plugins: {
legend: {
display: true,
labels: {
usePointStyle: true,
pointStyle: "rectRounded",
},
},
title: {
display: false,
text: "Use of App",
},
tooltip: {
callbacks: {
label: function (context: any) {
const label = context.label || "";
const value = context.parsed;
const total = context.dataset.data.reduce(
(a: number, b: number) => a + b,
0
);
const percentage = calculatePercentage(value, total);
return `${label}: ${value} (${percentage})`;
},
},
},
},
};
字符串
任何帮助将是惊人的!
1条答案
按热度按时间ha5z0ras1#
您需要将fontColor添加到有问题的对象:
个字符