Diagram's canvas size is very small

My diagram is placed inside an expander .
When the expander, expands the size of the canvas (inside diagram) is very small(width=1, height=1) and it is placed at top left (0,0)corner.when I press ‘F12’ (for debug) or any click on diagram , the size of the canvas become normal.

What is the reason for such behavior and how can i solve ?

http://gojs.net/latest/intro/resizing.html