Home forums Using CanvasJS CanvasJS with mobile mode.

Tagged: ,

This topic contains 2 replies, has 2 voices, and was last updated by  Tung Nguyen 1 year, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8969

    Tung Nguyen
    Member

    I created a project mobile android app. To customize screen with charts. I used bootstrap to create div(s) and put div of canvasJS chart inside. I want height and width of chart fit with div outside it.
    With chart div: set width and height to 100% and position: absolute;. With div outside: set position: relative;
    When I run with mobile app and open it. Width and height not fit until I change orientation.

    #8983

    Sunil Urs
    Keymaster

    Tung,

    Then you are probably calling chart.render() even before the width and height of Chart’s Container (DIV) is set/initialized by the browser. Basically you need to call chart.render() after the DIV is initialized by browser. In case you are not able to find a way to do that, you can work around such problems by calling chart.render() after a bit of delay by using setTimeout – something like 500ms or 1000ms should work.

    In case you are still not able to fix the issue, please create a jsfiddle so that we can have a look.


    Sunil Urs

    #8985

    Tung Nguyen
    Member

    Thanks Sunil Urs for supporting me. So, I can resolve it by edit height and width value default at canvasjs.js. If you don’t set height and width of div tag of charts inside DIV value before calling chart.render(), The size of DIV will take value height, width default at canvasjs.js.

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

You must be logged in to reply to this topic.