Home forums Feature Requests & Feedback Resize Canvas when parent-div got resized

Tagged: 

This topic contains 5 replies, has 3 voices, and was last updated by  vulturistic 1 year, 12 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #5487

    Helge
    Participant

    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.

    #5507

    Sunil Urs
    Keymaster

    Helge,

    Makes sense. I’ll consider implementing an API to explicitly call resize function in next version.


    Sunil

    #5529

    Helge
    Participant

    this sounds great.

    thank you

    #6001

    Sunil Urs
    Keymaster

    Helge,

    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

    #6003

    Helge
    Participant

    Thats great, thank you!

    #7583

    vulturistic
    Participant

    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.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.