score:16

Accepted answer

the documentation for chartjs states that you need to set maintainaspectratio to false for it to use the width and height props that you pass into your chart.

in order for chart.js to obey the custom size you need to set maintainaspectratio to false.

<doughnut
  data={data}
  width={"30%"}
  options={{ maintainaspectratio: false }}
/>

score:0

doing the following works for me:

  1. set height and width on the <doughnut /> component.
  2. set the maintainaspectration to false.

here is what the outcome looks like:

<doughnut
  data={data}
  height="200px"
  width="200px"
  options={{ maintainaspectratio: false }}
/>

score:2

wrap it in div container and set width and height.

ex:

<div style={{height:"60vh",position:"relative", marginbottom:"1%", padding:"1%"}}>
     <doughnut options={options} data={chartdata} />
</div>

Related Query

More Query from same tag