redraw google charts on hidden bootstrap tab pane

前端 未结 2 760
轮回少年
轮回少年 2021-02-10 02:55

I am using google scatter chart in my web app and it loads on document ready. I recently did some restructuring and trying to divide the page content in different bootstrap tabs

2条回答
  •  终归单人心
    2021-02-10 03:12

    Just incase other people are looking for a simpler solution.

    An alternative is to implement the following:

    $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
        var ev = document.createEvent('Event');
        ev.initEvent('resize', true, true);
        window.dispatchEvent(ev);
      });
    

    This will cause the chart to re-draw as if the browser was resized.

提交回复
热议问题