如何调整jQuery flot图表的大小?

如何调整jQuery flot图表的大小?,jquery,flot,Jquery,Flot,我有一个jQuery flot图表,其中包含以下代码: $("table.statics").each(function() { var colors = []; $("table.statics thead th:not(:first)").each(function() { colors.push($(this).css("color")); }); $(this).graphTable({ series: 'columns',

我有一个jQuery flot图表,其中包含以下代码:

$("table.statics").each(function() {
    var colors = [];
    $("table.statics thead th:not(:first)").each(function() {
        colors.push($(this).css("color"));
    });
    $(this).graphTable({
        series: 'columns',
        position: 'replace',
        height: '200px',
        colors: colors
    }, {
        xaxis: {
            tickSize: 1
        }
    });
});
这段代码运行良好,但现在我希望在调整窗口大小时调整图表的大小


我该怎么做?我的文档中包含jquery.flot.resize.js。

只需删除
“height:200px”
,然后给它
“height:40%”
或您想要的数值
在给定百分比时,您可以确保每次调整窗口大小时都会计算新的大小。

这是一个简单的解决方案-您只需在jquery.flot.pie.js中添加一行即可:

var attempts = 0;
redraw = true; /* <--add this as line #281 */
while (redraw && attempts<redrawAttempts) 
var尝试次数=0;

重画=真;/* 只需添加对flot图表附带的jquery.flot.resize.js插件的引用,就是这样

从插件文档:

Flot插件,用于在占位符 大小更改,例如在窗口调整大小时

它通过侦听占位符div上的更改(通过 jQuery resize事件插件)-如果大小更改,它将重新绘制 阴谋


可以从

下载调整大小的不是我想要的高度,而是图表的宽度。但我看到的宽度是一样的,thnx!:)这对我不起作用,也许语法不对@马斯特拉特写了高度:200px,而不是高度:200px