我有一个包含以下数据的圆环图组件:
const data = {
labels: ["1", "2"],
datasets: [
{
label: "peers",
data: [1, 2],
backgroundColor: ["#56E2CF", "#56AEE2"]
}
]
};
数据正常工作。以下是选项:
const options = {
legend: {
display: "right"
}
};
元件环圈图:
<Doughnut data={data} options={options} />
但图表仍然没有标题:
我尝试使用插件将选项设置为char.js样式:
const options = {
plugins: {
legend: {
position: "right"
}
}
};
图例移动,但出现类型错误(仍无标题):The types of 'plugins.legend.position' are incompatible between these types. Type 'string' is not assignable to type '"right" | "left" | "top" | "bottom" | "center" | "chartArea" | _DeepPartialObject<{ [scaleId: string]: number; }> | undefined'
请注意标题是如何向右移动的:
1条答案
按热度按时间cyvaqqii1#
下面是来自TypeScript文档的说明-https://devblogs.microsoft.com/typescript/announcing-typescript-3-4-rc/#const-assertions