4

For some reason my jqplot (from a plugin) has a fixed height. This question is directly for people who use this plugin. Do you know how to make the height dynamically change depending on that of its parent? Like via just a 100% height?

4

3 回答 3

3

我认为最好的方法是在初始化图表之前确定父容器的高度。容器也必须被拉伸以填充使用 CSS 技术为图表保留的空间。你可以这样做:

HTML:

<div class="container"><div id="chart"></div></div>

jQuery代码:

var containerHeight = $("#chart").parent("div.container").height();
var chart = $.jqplot('chart', [data], {
    height: containerHeight,
    ...
});

当然,这种方法并不适合所有的情况。

于 2013-03-20T11:10:25.140 回答
3

这就是我所做的。将 .96 更改为 1,您应该能够实现您想要的。

$('#ChartID').height($('#ParentElement').height() * 0.96);
$('#ChartID').width($('#ParentElement').width() * 0.96);

我在绘制图表后调用这些。

于 2012-07-14T00:11:16.753 回答
0

使用以下步骤;我认为绘制动态高度图很有用

var minHeight=100;

if (30 * label.length > minHeight){
minHeight = 30 * label.length;
}
$('#chart1').height(minHeight);
于 2017-02-20T09:51:47.410 回答