You must be logged in to post your query.
Home › Forums › Feature Requests & Feedback › Resize Canvas when parent-div got resized
Tagged: resize
Hello,
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.
Helge,
Makes sense. I’ll consider implementing an API to explicitly call resize function in next version.
— Sunil
this sounds great.
thank you
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.
— Sunil Urs
Thats great, thank you!
hi, 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 width: 600, title:{ 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.
Hi, 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…
@Oyehr,
Charts occupy the width of the container by default and readjust it’s size on resizing the container. Setting width property of the chart makes it unresponsive. To make the chart responsive, you need to set the width of the container instead of charts.
__ Priyanka M S Team CanvasJS
You must be logged in to reply to this topic. Login/Register