Resize issue while gridster.js with highcharts

前端 未结 3 1351
-上瘾入骨i
-上瘾入骨i 2021-01-06 23:42

Highcharts inside the gridster widgets not resize automatically when I resize the gridster widgets. When I resize the window, highchart are resized based on the grid sizes.

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-07 00:22

    According to the Highcharts api, automatic reflow only occurs on window.resize events. You'll have to do this explicitly. I'd simply do it in gridster's resize.stop callback:

    gridster = $(".gridster ul").gridster({
          widget_base_dimensions: [100, 55],
          widget_margins: [5, 5],
          helper: 'clone',
          resize: {
            enabled: true,
            stop: function(e, ui, $widget) {
              Highcharts.charts[0].reflow(); // reflow the first chart...
            }
          }
       }).data('gridster'); 
    

    Example fiddle here.

提交回复
热议问题