Home › forums › Using CanvasJS › CanvasJS with mobile mode.
Tagged: height, width
This topic contains 2 replies, has 2 voices, and was last updated by Tung Nguyen 3 years, 2 months ago.
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.
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.
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.
You must be logged in to reply to this topic.