You must be logged in to post your query.
Home › Forums › Feature Requests & Feedback › Resize Canvas when parent-div got resized
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.
I have met this, too. But the canvas still does not automatically resizes, when its parent-div got resized. If I am using the wrong version…
Charts occupy the width of the container and resize when the container resizes.
Setting width at the chart level makes it unresponsive. To make the charts responsive, set the width of the container and not charts.
Priyanka M S
You must be logged in to reply to this topic. Login/Register