From bfbfbfc49140e88753823e01abdc1ffc12e44ba2 Mon Sep 17 00:00:00 2001 From: Frank Wuerthwein Date: Mon, 16 Feb 2009 13:04:50 +0000 Subject: Move trim_data into a new class: rrdFlotSelection, in the rrdFlotSupport module --- src/lib/rrdFlotSupport.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/lib/rrdFlotSupport.js') diff --git a/src/lib/rrdFlotSupport.js b/src/lib/rrdFlotSupport.js index 8aa9e49..ede309c 100644 --- a/src/lib/rrdFlotSupport.js +++ b/src/lib/rrdFlotSupport.js @@ -43,3 +43,48 @@ function rrdDS2FlotSeries(rrd_file,ds_id,rra_idx,want_label) { } } +// ====================================== +// Helper class for handling selections +// ======================================================= +function rrdFlotSelection() { + this.selection_min=null; + this.selection_max=null; +} + +// reset to a state where ther is no selection +rrdFlotSelection.prototype.reset = function() { + this.selection_min=null; + this.selection_max=null; +} + +// given the selection ranges, set internal variable accordingly +rrdFlotSelection.prototype.setFromFlotRanges = function(ranges) { + this.selection_min=ranges.xaxis.from; + this.selection_max=ranges.xaxis.to; +} + +// Given an array of flot lines, limit to the selection +rrdFlotSelection.prototype.trim_flot_data = function(flot_data) { + var out_data=[]; + for (var i=0; i no filtering + + var out_data=[]; + for (var i=0; i=this.selection_min) && (nr<=this.selection_max)) { + out_data.push(data_list[i]); + } + } + return out_data; +}; + -- cgit v1.2.3-54-g00ecf