Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

how to prevent chrome change canvas attribute height and width

Open ghost opened this issue 10 years ago • 6 comments

I have canvas attribute width 544 and height 306

screen shot 2016-03-28 at 5 40 57 pm

but, when chart start to render my canvas attribute change

screen shot 2016-03-28 at 5 43 55 pm

and this my chart result in Firefox screen shot 2016-03-28 at 5 46 00 pm

in Chrome screen shot 2016-03-28 at 5 46 48 pm

ghost avatar Mar 28 '16 10:03 ghost

I found out that if you set responsive option to true than Chart.js resizes canvas according to parent width. If it is responsive=false than width and height are fixed as you wish.

ekatherina avatar Mar 28 '16 11:03 ekatherina

@hierarchy-id can you drop this in a JSFiddle?

etimberg avatar Mar 29 '16 23:03 etimberg

This is example - https://jsfiddle.net/jfkLvLd2/1/ Also you can try to use

responsive: true,
maintainAspectRatio: false

ekatherina avatar Mar 29 '16 23:03 ekatherina

@simonbrunel I think this is tied in with the resizing improvements you are working on

etimberg avatar Sep 24 '16 13:09 etimberg

Certainly, but I haven't been able to reproduce what @hierarchy-id have in his screenshots. Is the @ekatherina fiddle supposed to showcase the issue?

simonbrunel avatar Sep 24 '16 15:09 simonbrunel

Closing since no test case has been provided. The responsive implementation has been enhanced in version 2.4 and unit tests added (some of them might check the reported case).

simonbrunel avatar Nov 04 '16 21:11 simonbrunel