summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank Wuerthwein <fkw@ucsd.edu>2009-02-16 13:11:45 +0000
committerFrank Wuerthwein <fkw@ucsd.edu>2009-02-16 13:11:45 +0000
commit55cca35ef38c4972a1c99ba8f3a490f9c070a3b5 (patch)
tree4cfc7fc996194737738c5b13d03ab15d3302e4e5 /src
parentbfbfbfc49140e88753823e01abdc1ffc12e44ba2 (diff)
Add few more helper methods to rrdFlotSelection
Diffstat (limited to 'src')
-rw-r--r--src/lib/rrdFlot.js8
-rw-r--r--src/lib/rrdFlotSupport.js24
2 files changed, 20 insertions, 12 deletions
diff --git a/src/lib/rrdFlot.js b/src/lib/rrdFlot.js
index 146f816..3db3a27 100644
--- a/src/lib/rrdFlot.js
+++ b/src/lib/rrdFlot.js
@@ -200,20 +200,18 @@ rrdFlot.prototype.bindFlotGraph = function(flot_data) {
var graph_data=this.selection_range.trim_flot_data(flot_data);
//var scale_data=flot_data.clone();
var scale_data=flot_data;
-
var graph = $.plot($(graph_jq_id), graph_data, graph_options);
var scale = $.plot($(scale_jq_id), scale_data, scale_options);
- if (this.selection_min!=null) {
- scale.setSelection({ xaxis: {from: this.selection_min, to: this.selection_max}},true); //don't fire event, no need
+ if (this.selection_range.isSet()) {
+ scale.setSelection(this.selection_range.getFlotRanges(),true); //don't fire event, no need
}
// now connect the two
$(graph_jq_id).bind("plotselected", function (event, ranges) {
// do the zooming
- rf_this.selection_range.setFromFlotRanges(ranges);
- rf_this.selection_max=ranges.xaxis.to;
+ rf_this.selection_range.setFromFlotRanges(ranges);
graph = $.plot($(graph_jq_id), rf_this.selection_range.trim_flot_data(flot_data), graph_options);
// don't fire event on the scale to prevent eternal loop
diff --git a/src/lib/rrdFlotSupport.js b/src/lib/rrdFlotSupport.js
index ede309c..dc12f89 100644
--- a/src/lib/rrdFlotSupport.js
+++ b/src/lib/rrdFlotSupport.js
@@ -49,19 +49,29 @@ function rrdDS2FlotSeries(rrd_file,ds_id,rra_idx,want_label) {
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;
-}
+ 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;
-}
+ this.selection_min=ranges.xaxis.from;
+ this.selection_max=ranges.xaxis.to;
+};
+
+// Return a Flot ranges structure that can be promptly used in setSelection
+rrdFlotSelection.prototype.getFlotRanges = function() {
+ return { xaxis: {from: this.selection_min, to: this.selection_max}};
+};
+
+// return true is a selection is in use
+rrdFlotSelection.prototype.isSet = function() {
+ return this.selection_min!=null;
+};
// Given an array of flot lines, limit to the selection
rrdFlotSelection.prototype.trim_flot_data = function(flot_data) {