gpt4 book ai didi

jqplot 在调整浏览器大小时调整图表大小

转载 作者:行者123 更新时间:2023-12-03 01:57:00 26 4
gpt4 key购买 nike

有没有一种简单的方法可以在调整浏览器大小时自动调整 jqplot 图表的大小?我一直在 Google 上查找,但没有找到任何结果。

最佳答案

讨论了调整 jqplots 的大小 here .

要使其在浏览器大小调整时工作,请将 replot 函数与 window.resize 事件绑定(bind)在一起:

$(window).resize(function() {
plot1.replot( { resetAxes: true } );
});

运行代码:

$(document).ready(function(){
var plot1 = $.jqplot ('container', [[3,7,9,1,4,6,8,2,5]], {});

$(window).resize(function() {
plot1.replot( { resetAxes: true } );
});

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.8/jquery.jqplot.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.8/jquery.jqplot.min.css">

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

关于jqplot 在调整浏览器大小时调整图表大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11585267/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com