From f183804a8775d48d093103354168127849c8f717 Mon Sep 17 00:00:00 2001 From: Manuel Luis SanmartĂ­n Rozada Date: Sun, 3 Aug 2014 18:56:23 +0200 Subject: jsrrdgraph: Set original step when change time interval. --- js/RrdCmdLine.js | 1 + js/RrdGraph.js | 10 ++++++---- js/RrdJson.js | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/js/RrdCmdLine.js b/js/RrdCmdLine.js index c222498..48b3d9d 100644 --- a/js/RrdCmdLine.js +++ b/js/RrdCmdLine.js @@ -252,6 +252,7 @@ RrdCmdLine.prototype = { break; case 'step': this.graph.step = parseInt(value, 10); + this.graph.step_orig = this.graph.step; break; case 'start': case 's': diff --git a/js/RrdGraph.js b/js/RrdGraph.js index 038668e..c2457c9 100644 --- a/js/RrdGraph.js +++ b/js/RrdGraph.js @@ -210,8 +210,10 @@ RrdGraphDesc.prototype.def = function (graph, vname, rrdfile, name, cf, step, st this.ds_nam = name; this.cf = RrdGraphDesc.cf_conv(cf); - if (step != undefined && step != null) + if (step != undefined && step != null) { this.step = step; + this.step_orig = step; + } if (start != undefined && start != null) start_t = new RrdTime(start); if (end != undefined && end != null) @@ -757,6 +759,7 @@ var RrdGraph = function (gfx, data) this.watermark = null; /* watermark for graph */ this.tabwidth = 40; /* tabwdith */ this.step = 0; /* any preference for the default step ? */ + this.step_orig = 0; /* any preference for the default step ? */ this.setminval = Number.NaN; /* extreme values in the data */ this.setmaxval = Number.NaN; this.rigid = false; /* do not expand range even with values outside */ @@ -2650,11 +2653,10 @@ RrdGraph.prototype.graph_paint_init = function() this.minval = this.setminval; this.maxval = this.setmaxval; - this.step = Math.max(this.step, (this.end - this.start) / this.xsize); + this.step = Math.max(this.step_orig, (this.end - this.start) / this.xsize); for (var i = 0, gdes_c = this.gdes.length; i < gdes_c; i++) { - this.gdes[i].step = 0; // FIXME 0? - this.gdes[i].step_orig = this.step; + this.gdes[i].step = this.gdes[i].step_orig; this.gdes[i].start = this.start; // FIXME SHIFT // this.gdes[i].start_orig = this.start; this.gdes[i].end = this.end; // FIXME SHIFT diff --git a/js/RrdJson.js b/js/RrdJson.js index 4ddcbc2..eef555c 100644 --- a/js/RrdJson.js +++ b/js/RrdJson.js @@ -139,6 +139,7 @@ RrdJson.prototype = { break; case 'step': this.graph.step = this.json.step; + this.graph.step_orig = this.json.step; break; case 'start': this.graph.start_t = new RrdTime(this.json.start); -- cgit v1.1