【发布时间】:2021-08-15 03:33:59
【问题描述】:
有几个问题与我的思路相同。然而,这些问题只集中在 chart.js 上。我有类似的问题,但在 react-chart.js 上。 如何增加图例和图表之间的间距? 我使用过padding,但它只会增加图例之间的间距。不完全是我想要的。下面是我的圆环图组件。
<div className="dougnut-chart-container">
<Doughnut
className="doughnut-chart"
data={
{
labels: ["a", "b", "c", "d", "e", "f"],
datasets: [
{
label: "Title",
data: [12821, 34581, 21587, 38452, 34831, 48312],
backgroundColor: [
'rgb(61, 85, 69)',
'rgb(115, 71, 71)',
'rgb(166, 178, 174)',
'rgb(209, 191, 169)',
'rgb(66, 63, 62)',
'rgb(43, 43, 43)',
]
}
],
}
}
options={
{
plugins: {
legend: {
labels: {
color: "white",
font: {
size: 12
},
padding: 10,
},
position: "left",
title: {
display: true,
text: "Title",
color: "grey",
padding: 10
}
}
},
elements: {
arc: {
borderWidth: 0
}
},
responsive: true,
maintainAspectRatio: true,
}
}
/>
</div>
我的图表是什么样子的:
【问题讨论】:
标签: javascript reactjs chart.js react-chartjs