Home › forums › Feature Requests & Feedback › Resize Canvas when parent-div got resized
This topic contains 5 replies, has 3 voices, and was last updated by vulturistic 3 years, 7 months ago.
the canvas does not automatically resizes, when its parent-div got resized.
I have seen in the source-code, that the canvas resizes when the window-size is changed.
Automatically checking if parent-div has changed seems to be quite complicated, but if you could put the listener function to public, this would be nice.
So we could trigger it by hand, and take the responsibility, if its called to often.
Makes sense. I’ll consider implementing an API to explicitly call resize function in next version.
this sounds great.
In the latest version you can just call render method whenever its container’s size changes and the chart readjusts its size (only if required) and also redraws the chart to fit the new size. You can also explicitly set width and height (in pixels) of chart in chart options and call render method to update its size.
Thats great, thank you!
I have the same problem as yours, I fixed it by using the following code:
var chart = new CanvasJS.Chart(“chartContainer”,
height: 550, //in pixels
text: “Earthquakes – per month”
I have set the height and width inside the property of chart. I have encountered the same bug when I first set the height and width in my <div>. Hope this will help.
You must be logged in to reply to this topic.