While using rrdFlot within a project, I noticed that some Array iterations in rrdFlotSupport use an approach that fails under some circumstances. Specifically, the for..in construct fails when the Array prototype has been extended to have additional properties. I attach a patch that rectifies this problem.
Thanks for creating a very useful tool!
Cheers,
Mark.
--- rrdFlotSupport.js.orig 2012-05-09 12:06:27.000000000 +0100+++ rrdFlotSupport.js 2012-05-09 12:04:16.000000000 +0100@@ -66,7 +66,8 @@
var out_el={data:[], min:first_el*1000.0, max:last_update*1000.0};
- for (ds_list_idx in ds_list) {+ var ds_list_len = ds_list.length;+ for (var ds_list_idx=0; ds_list_idx<ds_list_len; ++ds_list_idx) {
var ds_id=ds_list[ds_list_idx];
var ds=rrd_file.getDS(ds_id);
var ds_name=ds.getName();
@@ -119,12 +120,14 @@
// first the stacks stack
var stack_els=[ds_positive_stack_list,ds_negative_stack_list];
- for (stack_list_id in stack_els) {+ var stack_els_len = stack_els.length;+ for (var stack_list_id=0; stack_list_id<stack_els_len; ++stack_list_id) {
var stack_list=stack_els[stack_list_id];
var tmp_flot_els=[];
var tmp_ds_ids=[];
var tmp_nr_ids=stack_list.length;
- for (ds_list_idx in stack_list) {+ var stack_list_len = stack_list.length;+ for (var ds_list_idx=0; ds_list_idx<stack_list_len; ++ds_list_idx) {
var ds_id=stack_list[ds_list_idx];
var ds=rrd_file.getDS(ds_id);
var ds_name=ds.getName();
@@ -179,7 +182,8 @@
}
} //end for stack_list_id
- for (ds_list_idx in ds_single_list) {+ var ds_single_list_len = ds_single_list.length;+ for (var ds_list_idx=0; ds_list_idx<ds_single_list_len; ++ds_list_idx) {
var ds_id=ds_single_list[ds_list_idx];
var ds=rrd_file.getDS(ds_id);
var ds_name=ds.getName();
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Igor,
While using rrdFlot within a project, I noticed that some Array iterations in rrdFlotSupport use an approach that fails under some circumstances. Specifically, the for..in construct fails when the Array prototype has been extended to have additional properties. I attach a patch that rectifies this problem.
Thanks for creating a very useful tool!
Cheers,
Mark.
Thanks!
Unfortunately your timing is a bit a problem to me… I am just about to take several weeks off to stay with my new baby,
I will review and integrate your patch into the next release once I get back.
Thanks again,
Igor
OK, patch committed.
You will get it if you grab the CVS head.
However, unless you really need it, I will not cut a new release just to include this patch.
Thanks again,
Igor