From a979994ca12b19f918953078278dfeab7e2a52b8 Mon Sep 17 00:00:00 2001 From: pyrocyon Date: Mon, 15 Aug 2011 22:25:40 +0000 Subject: Added support for tooltips. --- src/lib/rrdFlot.js | 11 +++++++++++ src/lib/rrdFlotMatrix.js | 11 +++++++++++ 2 files changed, 22 insertions(+) (limited to 'src/lib') diff --git a/src/lib/rrdFlot.js b/src/lib/rrdFlot.js index 9743d41..82050c4 100644 --- a/src/lib/rrdFlot.js +++ b/src/lib/rrdFlot.js @@ -438,6 +438,7 @@ rrdFlot.prototype.bindFlotGraph = function(flot_obj) { // Legend var oSelect=document.getElementById(this.legend_sel_id); var legend_id=oSelect.options[oSelect.selectedIndex].value; + var tooltip_enabled=this.graph_options.tooltip; //tooltip status var graph_jq_id="#"+this.graph_id; var scale_jq_id="#"+this.scale_id; @@ -448,6 +449,9 @@ rrdFlot.prototype.bindFlotGraph = function(flot_obj) { xaxis: { mode: "time" }, yaxis: { autoscaleMargin: 0.20}, selection: { mode: "x" }, + tooltip: true, + tooltipOpts: { content: "

%s

Value: %y.3" }, + grid: { hoverable: true }, }; if (legend_id=="None") { @@ -457,6 +461,13 @@ rrdFlot.prototype.bindFlotGraph = function(flot_obj) { graph_options.legend.position=legend_id; } + if (tooltip_enabled=="None"||tooltip_enabled==true) { + //nothing is the default -> tooltips displayed + } else if (tooltip_enabled==false) { + graph_options.grid.hoverable=false; + graph_options.tooltip=false; + } + if (this.selection_range.isSet()) { var selection_range=this.selection_range.getFlotRanges(); if(this.rrdflot_defaults.use_windows) { diff --git a/src/lib/rrdFlotMatrix.js b/src/lib/rrdFlotMatrix.js index 08c3239..25fa4f3 100644 --- a/src/lib/rrdFlotMatrix.js +++ b/src/lib/rrdFlotMatrix.js @@ -375,6 +375,7 @@ rrdFlotMatrix.prototype.bindFlotGraph = function(flot_obj) { // Legend var oSelect=document.getElementById(this.legend_sel_id); var legend_id=oSelect.options[oSelect.selectedIndex].value; + var tooltip_enabled=this.graph_options.tooltip; //tooltip status. var graph_jq_id="#"+this.graph_id; var scale_jq_id="#"+this.scale_id; @@ -385,6 +386,9 @@ rrdFlotMatrix.prototype.bindFlotGraph = function(flot_obj) { xaxis: { mode: "time" }, yaxis: { autoscaleMargin: 0.20}, selection: { mode: "x" }, + tooltip: true, + tooltipOpts: { content: "

%s

Value: %y.3" }, + grid: { hoverable: true }, }; @@ -395,6 +399,13 @@ rrdFlotMatrix.prototype.bindFlotGraph = function(flot_obj) { graph_options.legend.position=legend_id; } + if (tooltip_enabled=="None"||tooltip_enabled==true) { + //nothing is the default -> tooltips displayed + } else if (tooltip_enabled==false) { + graph_options.grid.hoverable=false; + graph_options.tooltip=false; + } + if (this.selection_range.isSet()) { var selection_range=this.selection_range.getFlotRanges(); graph_options.xaxis.min=selection_range.xaxis.from; -- cgit v1.2.3-2-g168b