From 662bab1374c80b6d81cc89f18acb712b488482f9 Mon Sep 17 00:00:00 2001 From: Frank Wuerthwein Date: Sun, 10 May 2009 00:24:53 +0000 Subject: Add rrdRRAMultiStackFlotObj --- src/lib/rrdFlotSupport.js | 99 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/src/lib/rrdFlotSupport.js b/src/lib/rrdFlotSupport.js index 3110eda..499aca1 100644 --- a/src/lib/rrdFlotSupport.js +++ b/src/lib/rrdFlotSupport.js @@ -95,7 +95,7 @@ function rrdRRA2FlotObj(rrd_file,rra_idx,ds_list,want_ds_labels,want_rounding) { // return an object with an array containing Flot elements // have a positive and a negative stack of DSes, plus DSes with no stacking // min and max are also returned -// If one_undefined_enough==true, a whole stack is invalidated is a single element +// If one_undefined_enough==true, a whole stack is invalidated if a single element // of the stack is invalid function rrdRRAStackFlotObj(rrd_file,rra_idx, ds_positive_stack_list,ds_negative_stack_list,ds_single_list, @@ -206,6 +206,103 @@ function rrdRRAStackFlotObj(rrd_file,rra_idx, return out_el; } +// return an object with an array containing Flot elements, one per RRD +// min and max are also returned +function rrdRRAMultiStackFlotObj(rrd_files, // a list of [rrd_id,rrd_file] pairs, all rrds must have the same step + rra_idx,ds_id, + want_rrd_labels,want_rounding, + one_undefined_enough) { // If true, a whole stack is invalidated if a single element of the stack is invalid + + var reference_rra=rrd_files[0][1].getRRA(rra_idx); // get the first one, all should be the same + var rows=reference_rra.getNrRows(); + var step=reference_rra.getStep(); + var ds_idx=rrd_files[0][1].getDS(ds_id).getIdx(); // this can be expensive, do once (all the same) + + // rrds can be slightly shifted, calculate range + var max_ts=null; + var min_ts=null; + + // initialize list of rrd data elements + var tmp_flot_els=[]; + var tmp_rras=[]; + var tmp_last_updates=[]; + var tmp_nr_ids=rrd_files.length; + for (var id=0; idmax_ts)) { + max_ts=rrd_last_update; + } + if ((min_ts==null) || (rrd_min_ts=0) && (row_delta