Highcharts item width not 100% in carousel

后端 未结 1 1961
萌比男神i
萌比男神i 2021-01-21 06:03

I\'m dynamically creating highcharts graphs in my bootstrap carousel.

I have a carousel like this:

相关标签:
1条回答
  • 2021-01-21 06:26

    It seems that the charts need a window resize since the carousel slides aren't loaded into the dom, besides the active slide. You could add something like this to your code to make it resize on the slide event.

    $('.carousel').carousel({
        interval: 3000
    }).bind('slide.bs.carousel', function() {
        setTimeout(function() {$(window).trigger('resize')} , 1);           
    });
    

    You would want to use a setTimeout to allow the next slide to appear in the dom before resizing the window.

    0 讨论(0)
提交回复
热议问题