Как изменить цвет метки кольцевой диаграммы из реакции-chartjs-2
Я использую кольцевую диаграмму из реакции-chartjs-2, а цвет метки по умолчанию черный, я хочу его изменить.
Это мои объекты данных и параметров
export const data = {
labels: ["Left", "Remaining"],
datasets: [
{
data: [3, 7],
backgroundColor: ["#1f2733", "white"],
borderColor: ["#1f2733", "white"],
},
],
};
export const options = {};
export const textCenter = {
id: "textCenter",
beforeDatasetsDraw(chart, args, pluginOptions) {
const { ctx, data } = chart;
ctx.save();
ctx.font = "bolder 20px Roboto";
ctx.fillStyle = "white";
ctx.textAlign = "center";
ctx.textBaseLine = "middle";
ctx.fillText(
`${data.datasets[0].data[0]} Days Left`,
chart.getDatasetMeta(0).data[0].x,
chart.getDatasetMeta(0).data[0].y
);
},
};
это компонент реакции для кольцевой диаграммы
import React from "react";
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from "chart.js";
import { Doughnut } from "react-chartjs-2";
import { data, options, textCenter } from "./config";
ChartJS.register(ArcElement, Tooltip, Legend);
const DoughnutChart = () => {
return (
<Doughnut data={data} options={options} plugins={[textCenter]}></Doughnut>
);
};
export default DoughnutChart;
Я попробовал это, я думаю, это подходит дляchart.js, но цвет не изменился.
export const options = {
legend: {
labels: {
fontColor: "white"
},
}.
}