Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

highcharts graphs in bootstrap tabs are not displaying properly

I have two tabs, tab 1 and tab 2, when the page is initially loaded, the graph in the first tab is loaded at the same time, which is fitting right in col-md-6, now, when I click tab 2, the graph in that tab gets collapsed to almost half of the first one, I want it to also fit in the col-md-6 right and fine, Is there anything I'm doing wrong?

Please, have a look at this jsfiddle

like image 997
Bilal Ahmed Avatar asked Mar 12 '23 13:03

Bilal Ahmed


1 Answers

use this jquery tab select function, it will solve your problem.

here is modified fiddle click here

 jQuery(document).on( 'shown.bs.tab', 'a[data-toggle="tab"]', function (e) { // on tab selection event
    jQuery( "#graph-container-gray, #graph-container-red" ).each(function() {
        var chart = jQuery(this).highcharts(); // target the chart itself
        chart.reflow() // reflow that chart
    });
})
like image 64
Udhay Titus Avatar answered Mar 16 '23 07:03

Udhay Titus