如何更改Chartjs标签的字体颜色

ssm49v7z  于 5个月前  发布在  Chart.js
关注(0)|答案(1)|浏览(63)

我在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})`;
          },
        },
      },
    },
  };

字符串
任何帮助将是惊人的!

ha5z0ras

ha5z0ras1#

您需要将fontColor添加到有问题的对象:

fontColor: "blue",

个字符

相关问题