[BUG] Padding inside the chart
See original GitHub issueExpected Behavior
chart will be added within the limit of the container.
Current Behavior
chart is added with big padding.
Steps to Reproduce (for bugs)
index.html:
<body>
<div id="wrapper">
<canvas id="chart-area"></canvas>
</div>
<script src="../Chart.js/dist/Chart.js"></script> <!--included chartsJS Version: 2.5.0 -->
<script src="js/main.js"></script>
</body>
main.js:
var config = {
type: 'doughnut',
data: {
datasets: [{
data: [
30, 70
],
backgroundColor: [
'#ee7422',
'#0f4e6c',
],
label: 'Dataset 1'
}],
},
// layout is a try to fix the problem, but it doesn't have any effect. the problem persist with or without this property.
options: {
layout: {
padding: 0,
},
responsive: true,
circumference: Math.PI * 1,
rotation: Math.PI * -1,
cutoutPercentage: 30,
elements: {
arc: {
borderWidth: 0,
}
},
}
};
window.onload = function () {
var ctx = document.getElementById("chart-area").getContext("2d");
window.myDoughnut = new Chart(ctx, config);
};
Picture:
Cavnas takes up the whole screen, and leave big paddings , which break the flow of the DOM.
Context
i have to fix the graph inside a box, and wrap it with other content. the big padding disturn the flow of the DOM.
Environment
- Chart.js version: 2.5.0
- Chrome: Version 56.0.2924.87 (64-bit)
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
how to fix Chart.js bubble inner padding problem
How remove chat inner plot padding? It shows when i have big bobble radius. I try search in chart.js documentation, and in stack...
Read more >Padding in Chart JS - YouTube
Padding in Chart JSHow to add padding in Chart JS. In chart js adding padding is different as doing normal padding in css...
Read more >Padding - Chart.js
Padding values in Chart options can be supplied in a couple of different ... For example, defining a 20px padding to all sides...
Read more >padding(_:_:) | Apple Developer Documentation
Adds an equal padding amount to specific edges of this view. ... An amount, given in points, to pad this view on the...
Read more >How do I remove all padding around an Android Pie Chart?
I would like to be able to have a Pie Chart go to the very edge of the layout it's inside. Curre...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s definitely not a bug 😃 The chart size doesn’t depend on what’s drawn inside (that’s the other way actually). Doughnut charts have a default aspect ratio of 1 (square), so you can try to either set the option
aspectRatio: 2
(horizontal rectangle), which I guess is what you expect or set an initial size on your canvas that respect the proportions you want (e.g.<canvas width="300" height="150"/>
).Thank youuuuuuuuuuuuuu