Sarah Al
Sarah Al

Reputation: 13

Chart.js reduce canvas size without changing the size of the chart

I have a radar chart with the following canvas properties:

ctx.canvas.width = 600;
ctx.canvas.height = 550;

The chart displays fine but the canvas seems too large as the chart has a lot of white space around it. I have tried reducing the size of the canvas but this reduces the size of the chart which I do not want.

Any advice?

Regards,

Sarah

Upvotes: 1

Views: 2650

Answers (2)

Joshua Schlichting
Joshua Schlichting

Reputation: 3450

You have to set responsible to false, per this SO duplicate question / answer: https://stackoverflow.com/a/43281488/3589609

 options: {
                responsive: false
            }

Upvotes: 1

rukimira
rukimira

Reputation: 66

Why don't you initialize the canvas with smaller dimensions then?

<canvas id="myChart" width="400" height="400"></canvas>

Upvotes: 0

Related Questions