admin管理员组文章数量:1297182
I've created a series of plots using the flot library, which are all displayed on a single page. Is there a way to update the X axis min and max options (options.xaxis.min, options.axis.max) values WITHOUT re-plotting the plots ($.plot('placeholder',data,options))?
I found this solution: .html Which suggests that the following line would do it, but it does not work for me - the plots visible min and max are not modified based on this call.
monitorGraph.getOptions().xaxis[0].max = xaxis.max;
Any tips on updating the graphs xaxis max and min values would be greatly appreciated!
EDIT: Solution Below
The following code will take an existing plot, update the range that is visible, and redraw it in a very light and efficient way.
plot.getOptions().xaxis[0].min = time.start;
plot.getOptions().xaxis[0].max = time.end;
plot.setupGrid();
plot.draw();
I've created a series of plots using the flot library, which are all displayed on a single page. Is there a way to update the X axis min and max options (options.xaxis.min, options.axis.max) values WITHOUT re-plotting the plots ($.plot('placeholder',data,options))?
I found this solution: http://osdir.com/ml/flot-graphs/2012-02/msg00064.html Which suggests that the following line would do it, but it does not work for me - the plots visible min and max are not modified based on this call.
monitorGraph.getOptions().xaxis[0].max = xaxis.max;
Any tips on updating the graphs xaxis max and min values would be greatly appreciated!
EDIT: Solution Below
The following code will take an existing plot, update the range that is visible, and redraw it in a very light and efficient way.
plot.getOptions().xaxis[0].min = time.start;
plot.getOptions().xaxis[0].max = time.end;
plot.setupGrid();
plot.draw();
Share
Improve this question
edited Mar 15, 2018 at 5:32
Jacob Hulse
8591 gold badge10 silver badges21 bronze badges
asked Jul 18, 2013 at 23:03
jfaghihnassirijfaghihnassiri
5232 gold badges4 silver badges17 bronze badges
1
- To specify futher: I would like the plots to reflect the new x min and max, but I would not like to re-plot them completely, since that is very expensive and seems to be slowing down the process. – jfaghihnassiri Commented Jul 18, 2013 at 23:07
2 Answers
Reset to default 12After you set the value of the yaxis max height, try
yourPlot.setupGrid();
Not sure if it'll be as smooth as you want but I think it does the trick.
You can also dynamically modify MIN/MAX parameters in axis options:
plot.getAxes().xaxis.options.min = 0;
plot.getAxes().xaxis.options.max = 999;
plot.setupGrid();
plot.draw();
本文标签: javascriptChanging axis minmax on an existing plot using Flot JQuery LibraryStack Overflow
版权声明:本文标题:javascript - Changing axis minmax on an existing plot using Flot JQuery Library - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738439877a2086896.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论