jQuery UI Tabs and Highcharts display/rendering issue

前端 未结 13 2383
长发绾君心
长发绾君心 2020-12-28 18:57

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 s

13条回答
  •  渐次进展
    2020-12-28 19:31

    This is my solution (only tested in Safari and Firefox). It works great if you want to load the chart into a hidden tab on a page with flexible width. The chart resize if the browser window is resized.

    In the chart settings, set the width of the chart from the tab that opens on page load (using jQuery to get the width):

       var chart = new Highcharts.Chart({
         chart: {
           renderTo: 'container',
           type: 'column',
           width: $('#tab-1').width()
         },
         ....
    

    The following function adjusts width if the browser window is resized. 500 is the height. This is done automatically if the width is not specified in the chart options.

    $(window).resize(function() {
       chart.setSize($('#chart_tab').width(),500);       
    });
    

提交回复
热议问题