summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralisonjm <alisonjm>2011-06-09 18:23:42 +0000
committeralisonjm <alisonjm>2011-06-09 18:23:42 +0000
commit9208e7621ae494b103e165c70fbb303184a0a10e (patch)
tree9419af5510884f155193b59d1b22feccfb844841
parent8d0015e0d6fc7a55f68fe22ab5e7ab73edf04118 (diff)
Moved timezone selection window to lower corner in flot graph.
-rw-r--r--src/lib/rrdFlot.js39
-rw-r--r--src/lib/rrdFlotSupport.js8
2 files changed, 39 insertions, 8 deletions
diff --git a/src/lib/rrdFlot.js b/src/lib/rrdFlot.js
index a8fbeac..9743d41 100644
--- a/src/lib/rrdFlot.js
+++ b/src/lib/rrdFlot.js
@@ -73,6 +73,7 @@
* graph_width: "500px" //Width of main graph.
* scale_height: "110px" //Height of small scaler graph.
* scale_width: "250px" //Width of small scaler graph.
+ * timezone: 0 //timezone.
* }
*/
@@ -81,6 +82,7 @@ var selected_rra = 0;
var window_min=0;
var window_max=0;
var elem_group=null;
+var timezone_shift=0;
function rrdFlot(html_id, rrd_file, graph_options, ds_graph_options, rrdflot_defaults) {
this.html_id=html_id;
@@ -118,6 +120,7 @@ rrdFlot.prototype.createHTML = function() {
this.graph_id=this.html_id+"_graph";
this.scale_id=this.html_id+"_scale";
this.legend_sel_id=this.html_id+"_legend_sel";
+ this.time_sel_id=this.html_id+"_time_sel";
this.elem_group_id=this.html_id+"_elem_group";
// First clean up anything in the element
@@ -170,6 +173,7 @@ rrdFlot.prototype.createHTML = function() {
cellScaleLegend.vAlign="top";
cellScaleLegend.appendChild(document.createTextNode("Legend:"));
cellScaleLegend.appendChild(document.createElement('br'));
+
var forScaleLegend=document.createElement("Select");
forScaleLegend.id=this.legend_sel_id;
forScaleLegend.appendChild(new Option("Top","nw",this.rrdflot_defaults.legend=="Top"));
@@ -180,6 +184,23 @@ rrdFlot.prototype.createHTML = function() {
forScaleLegend.onchange= function () {rf_this.callback_legend_changed();};
cellScaleLegend.appendChild(forScaleLegend);
+
+ cellScaleLegend.appendChild(document.createElement('br'));
+ cellScaleLegend.appendChild(document.createTextNode("Timezone:"));
+ cellScaleLegend.appendChild(document.createElement('br'));
+
+ var timezone=document.createElement("Select");
+ timezone.id=this.time_sel_id;
+
+ var timezones = ["+12","+11","+10","+9","+8","+7","+6","+5","+4","+3","+2","+1","0",
+ "-1","-2","-3","-4","-5","-6","-7","-8","-9","-10","-11","-12"];
+ for(var j=0; j<24; j++) {
+ timezone.appendChild(new Option(timezones[j],timezones[j],this.rrdflot_defaults.timezone==timezones[j]));
+ }
+ timezone.onchange= function () {rf_this.callback_timezone_changed();};
+
+ cellScaleLegend.appendChild(timezone);
+
var cellScale=rowScale.insertCell(-1);
cellScale.align="right";
var elScale=document.createElement("Div");
@@ -368,10 +389,14 @@ rrdFlot.prototype.drawFlotGraph = function() {
local_checked_DSs.push(ds_name);
}
}
-
+
+ var timeSelect=document.getElementById(this.time_sel_id);
+ timezone_shift=timeSelect.options[timeSelect.selectedIndex].value;
+
// then extract RRA data about those DSs
var flot_obj=rrdRRAStackFlotObj(this.rrd_file,rra_idx,
- ds_positive_stack_list,ds_negative_stack_list,ds_single_list);
+ ds_positive_stack_list,ds_negative_stack_list,ds_single_list,
+ timezone_shift*3600);
// fix the colors, based on the position in the RRD
for (var i=0; i<flot_obj.data.length; i++) {
@@ -549,6 +574,11 @@ rrdFlot.prototype.callback_scale_reset = function() {
rrdFlot.prototype.callback_legend_changed = function() {
this.drawFlotGraph();
};
+
+rrdFlot.prototype.callback_timezone_changed = function() {
+ this.drawFlotGraph();
+};
+
rrdFlot.prototype.callback_elem_group_changed = function(num) { //,window_min,window_max) {
var oCB=document.getElementById(this.ds_cb_id);
@@ -568,11 +598,12 @@ function getGraphInfo() {
graph_info['rra'] = selected_rra;
graph_info['window_min'] = window_min;
graph_info['window_max'] = window_max;
+ graph_info['timezone'] = timezone_shift;
return graph_info;
-}
+};
function resetWindow() {
window_min = 0;
window_max = 0;
-}
+};
diff --git a/src/lib/rrdFlotSupport.js b/src/lib/rrdFlotSupport.js
index 116dc35..607ec0b 100644
--- a/src/lib/rrdFlotSupport.js
+++ b/src/lib/rrdFlotSupport.js
@@ -99,7 +99,7 @@ function rrdRRA2FlotObj(rrd_file,rra_idx,ds_list,want_ds_labels,want_rounding) {
// of the stack is invalid
function rrdRRAStackFlotObj(rrd_file,rra_idx,
ds_positive_stack_list,ds_negative_stack_list,ds_single_list,
- want_ds_labels,want_rounding,one_undefined_enough) {
+ timestamp_shift, want_ds_labels,want_rounding,one_undefined_enough) {
var rra=rrd_file.getRRA(rra_idx);
var rra_rows=rra.getNrRows();
var last_update=rrd_file.getLastUpdate();
@@ -115,7 +115,7 @@ function rrdRRAStackFlotObj(rrd_file,rra_idx,
var first_el=last_update-(rra_rows-1)*step;
- var out_el={data:[], min:first_el*1000.0, max:last_update*1000.0};
+ var out_el={data:[], min:(first_el+timestamp_shift)*1000.0, max:(last_update+timestamp_shift)*1000.0};
// first the stacks stack
var stack_els=[ds_positive_stack_list,ds_negative_stack_list];
@@ -164,7 +164,7 @@ function rrdRRAStackFlotObj(rrd_file,rra_idx,
}
// fill the flot data
for (var id=0; id<tmp_nr_ids; id++) {
- tmp_flot_els[id].data.push([timestamp*1000.0,ds_vals[id]]);
+ tmp_flot_els[id].data.push([(timestamp+timestamp_shift)*1000.0,ds_vals[id]]);
}
}
} // end if
@@ -190,7 +190,7 @@ function rrdRRAStackFlotObj(rrd_file,rra_idx,
for (var i=0;i<rra_rows;i++) {
var el=rra.getEl(i,ds_idx);
if (el!=undefined) {
- flot_series.push([timestamp*1000.0,el]);
+ flot_series.push([(timestamp+timestamp_shift)*1000.0,el]);
}
timestamp+=step;
} // end for