I am trying to use a flot chart inside of a bootstrap tab, all though the javascript doesn't draw the chart correctly, its getting drawn distorted, the texts are too close to the graph..
<div id="tab3" class="tab-pane fade">
<div class="chart_flot" style="width:600px;height:300px;"></div>
</div>
Outside of the tab, the chart works fine. I've tried playing with around with css, but the only solution I've found is NOT setting the tabs style ( display:none ) as default , before tab selected, for example:
<div id="tab3" class="tab-pane fade" style="display:block">
<div class="chart_flot" style="width:600px;height:300px;"></div>
</div>
I've tried to set display:block on the tab that is used for the chart, and the graph got drawn fine but on other tab selection the canvas wouldn't disappear .
Solution.
I remind that this is a chart inside bootstrap default tabs bug. The reason it has been drawn distorted is because the chart cannot be drawn correctly in a hidden div ( display:none ) .
There are 3 options fixing this issue.
Easy way, with css
#tabid {
width:0;
display:block;
visibility:hidden;
height:0;
}
#tabid.active {
width:100%;
height:100%;
visibility:visible;
}
I hope this is going to be useful for some people.
Solution.
I remind that this is a chart inside bootstrap default tabs bug. The reason it has been drawn distorted is because the chart cannot be drawn correctly in a hidden div ( display:none ) .
There are 3 options fixing this issue.
Easy way, with css
width:0;
display:block;
visibility:hidden;
height:0;
}
width:100%;
height:100%;
visibility:visible;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With