Closed rob2360 closed 8 years ago
Can confirm I am doing the exact same thing at the moment.
Shifting the charts to a single tab-pane div generates the chart just fine. When the chart model is injected into the dom via js but something with the bootstrap tab-panes is preventing it from being generated.
Would love a fix.
I've been working on it to find a solution... But not easy to fix it. The problem is the responsive option set to true. If you remove it, it works much better. A first draft is available in Samples\bootstrap.htm.
I check if I can fix it for responsive option.
Did some research and found a work around, granted it's dirty (more of a dodge than a solution). add this quick resize event to your jquery doc ready call. The below snippet works cross-browser:
$('a[data-toggle=tab').on('shown.bs.tab', function (e) {
if (document.createEvent) { // W3C
var ev = document.createEvent('Event');
ev.initEvent('resize', true, true);
window.dispatchEvent(ev);
} else { // IE
document.fireEvent('onresize');
}
});
This is fired on the tab swap function and dispatches a resize event. I haven't tested it, but I believe this will only work if you are passing the responsive property in your chart options as a resize would not affect a non-responsive chart.
Try it out and let me know your mileage.
Updated snippet to be cross-browser.
A new version of "Samples\bootstrap.html" is available; it use a new add-ins (Add-ins\bootstrap_ChartNew.js).
@rob2360 & @davidsanders : Can you try it and give your feed-back about this version ?
@davidsanders : thanks - you give me a good tips.
I have ChartNew working well with multiple charts on one page. Want to split them up so that it is one chart per bootstrap tab. When I do this each chart is just a blank canvas.
Code snippit is below. Think it is to do with the tab not being visible at the time of creation but not sure best way to resolve.