jQuery UI Tabs and Highcharts display/rendering issue

匿名 (未验证) 提交于 2019-12-03 02:05:01

问题:

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             } 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!