question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pie / doughnut full responsive width

See original GitHub issue

I first thought this was an issue with the original chartjs, but found out that the following is an issue with react-chartjs-2:

When creating a pie or doughnut chart, the full width is not utilized.

When using vanilla chartjs, as you can see on this codepen, the full available width gets used, which increases the size of the chart. In the demonstrations of react-chartjs-2 you can see that pie/doughnut charts are reduced in size because they do not utilize the full width. Try viewing this on a mobile device (or with your browser’s developer tools in responsive mode). The chart becomes very small in size and could’ve been bigger.
A solution is indeed by changing the sizes manually, but this defeats the purpose of being a responsive chart.

Why is the pie/doughnut chart not utilizing the full width available of its parent container?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

4reactions
storesbuzzcommented, May 3, 2018

I too had same issue with doughnut chart, inner circle not getting full width. getting shrink leaving 90% side space blank.

I changed these two value and it’s full width now. responsive: true, maintainAspectRatio: false,

3reactions
JHanLucommented, Jun 11, 2018
options = {
  legend: {
    display: false
  }
}

Works for me!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chart.JS full-width, responsive doughnut chart with Bootstrap
I want the height to be responsive to whatever my .col-xs-8 's width is, and fill the entire div. I understand that I...
Read more >
Responsive Charts - Chart.js
When it comes to changing the chart size based on the window size, a major limitation is that the canvas render size (...
Read more >
Pie / Donut Chart Guide & Documentation - ApexCharts.js
Note that the size which you set there won't be responsive and will be fixed regardless the available width around it.
Read more >
Responsive and editable donut charts components in Figma
So here is the challenge I've faced: how to create a truly responsive donut chart component (or any chart that has to scale...
Read more >
width - Sets the Chart Width | CanvasJS JavaScript Charts
width : 320, . . }); chart.render(); ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found