开发者

Resize a chart on parent div resize

开发者 https://www.devze.com 2023-01-14 06:24 出处:网络
Hopefully someone can help me with something that has been bugging me. I\'ve got a page that is based on a fluid grid system. I\'m using the gvchart plug-in: http://www.ivellios.toron.pl/technikalia/2

Hopefully someone can help me with something that has been bugging me.

I've got a page that is based on a fluid grid system. I'm using the gvchart plug-in: http://www.ivellios.toron.pl/technikalia/2010/06/22/gvchart-plugin-jquery-with-google-charts/ to use generate Google charts from a table. Everything works fine except when the browser is resized elements begin to overlay as the chart has a set width in the JS e.g.:

jQuery('#myTable').gvChart({
    chartType: 'AreaChart',
    gvSettings: {
        vAxis: {title: 'No of players'},
        hAxis: {title: 'Month'},
        width: 600,
        height: 300
    }
});

So is there anyway to have it so when the browser is resized the chart is regenerated to开发者_如何学Go the correct width of the parent element?


You can set the dimensions of the chart on resize event of window.

$(window).resize(function() {
    resetDimensions();
});

resetDimensions is the method where you set width and height of the graph.

0

精彩评论

暂无评论...
验证码 换一张
取 消