如何调整 jQuery 流程图的大小?
我有一个带有以下代码的 jQuery 流程图:
$("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 。
I have a jQuery flot chart with this code:
$("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
}
});
});
This code is working fine, but now I want that the chart to resize when the window is resized.
How can i do this? I have the jquery.flot.resize.js included in my document.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需添加对 flot 图表附带的 jquery.flot.resize.js 插件的引用即可。
来自插件文档:
可以从 http://www.flotcharts.org/ 下载
Just add reference to jquery.flot.resize.js plugin that comes with flot charts and this is it.
From plugin documentation:
Could be downloaded from http://www.flotcharts.org/
这是一个简单的修复 - 您只需向 jquery.flot.pie.js 添加一行:
我从这里得到了解决方案:
https://github.com/flot/flot/commit/a2c38dc96489a217127c614879fa4dc9c8142f10#diff-0
This is an easy fix - you just need to add one line to jquery.flot.pie.js:
I got the solution from here:
https://github.com/flot/flot/commit/a2c38dc96489a217127c614879fa4dc9c8142f10#diff-0
只需删除
"height:200px"
并为其指定"height:40%"
或您想要的金额。在给出百分比时,您可以确保每次调整窗口大小时都会重新计算大小。
Simply delete the
"height:200px"
and give it"height:40%"
or the amout you want.In giving percent you ensure that the size is calculated new everytime when the window is resized.