可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Anyone ever used the tabs (jquery-ui-1.8.9
) and pie charts from Highcharts 2.1.4
together? To put it simply, I have multiple tabs, where each tab shows a pie chart with different data. The charts DO render to the divs, but when I click on the 2nd tab, the chart somehow shows up 300px
to the right of where it's suppose to be. Whenever I zoom in or out of the browser window, the chart goes back to the correction position.
My code:
//Suppose the number tabs are generated based on variable $count, and there are 2 tabs
回答12:
add class="chart"
to all highcharts containers inside tabs.
add this jQuery code:
jQuery(document).on( 'shown.bs.tab', 'a[data-toggle="tab"]', function () { $( '.chart' ).each(function() { $(this).highcharts().reflow(); }); })
回答13:
This worked for me after adding the class name (contains-chart) in the tabs
jQuery(document).on('shown.bs.tab', 'a[data-toggle="tab"]', function (e) { // on tab selection event jQuery(".contains-chart").each(function () { // target each element with the .contains-chart class var chart = jQuery(this).highcharts(); // target the chart itself chart.reflow() // reflow that chart }