我如何减少chartjs甜甜圈图的边框宽度

问题描述 投票:0回答:2

这是我要从模型中实现的目标:

“甜甜圈图图像”“>

但这是我到目前为止使用chartjs实现的功能:

“甜甜圈图图像”“>

这是我的代码

 datasets: [
            {
              data: [3, 8, 13, 9, 2],
              backgroundColor: [
                "#D51F1F",
                "#9B51E0",
                "#F2994A",
                "#4BD37B",
                "#4285F4"
              ],
            borderColor: [
                'rgba(255, 99, 132, 1)',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
            ],
            borderWidth:1,
            borderDash:[],
            borderStyle:'dash',
            line: { borderWidth:1 }
        }]
    }

    const options= {
        responsive: false,
        maintainAspectRatio: false,
        percentageInnerCutout : 0,
     }

我将borderWidth

设置为1
,似乎没有使边框变细。

这是我要从模型中实现的目标:但是,这是我到目前为止使用chartjs实现的目标:这是我的代码数据集:[{数据:[3、8、13、9、2], ...

javascript reactjs chart.js donut-chart react-chartjs
2个回答
0
投票
<Chart
options={{
            title: 'Status of Patients',
            pieHole: 0.4,   //this will change the hole size
            legend:'top',  //with this you can place desc of each piece
         }}  
 />

0
投票

在您的选项中添加cutoutPercentage: 80。您可以增加它以使甜甜圈图中间的白色区域变大,或减小它以使其变小。您需要弄乱它,以使图表尽可能接近示例。

© www.soinside.com 2019 - 2024. All rights reserved.