dygraphs div not visible until browser Inspection window opened or browser resize

后端 未结 2 1170
无人共我
无人共我 2021-01-05 21:48

This has plagued me for a week, so I had to come to SO. (Forgive the URL, it\'s a dev server). http://www.stagestudio.com.ua/shutter_stat/wiev_base.php?cat=34

when I

2条回答
  •  心在旅途
    2021-01-05 22:38

    This is a known issue that comes up from time to time. If a

    is invisible, then it doesn't have any well-defined height or width. So rendering a chart in it doesn't do anything useful (it has zero height). dygraphs has no way of knowing that the chart
    has become visible. This is really a gap in the DOM Events API. Other libraries like Google Maps have similar issues.

    Workarounds are:

    • You can call .resize() without any parameters to force a redraw when the popup appears.
    • You can create the chart when the popup appears, rather than on page load. This way it the chart
      will have a size when the chart is rendered.
    • You can assign the height and width explicitly, either in the dygraphs constructor or as styles on the chart
      .

提交回复
热议问题