Author:   Lars Michelsen <[email protected]>
Date:     Thu Nov 24 09:37:47 2011 +0100
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Thu Nov 24 09:37:47 2011 +0100

Added new config option line_label_y_offset to configure the label
offset used in weathermap lines which show percentage and absolute
bandwidth labels

---

 ChangeLog                                          |    2 +
 docs/en_US/map_config_format_description.html      |    7 +++++
 share/frontend/nagvis-js/js/NagVisLine.js          |    3 +-
 .../frontend/nagvis-js/js/NagVisStatefulObject.js  |    3 +-
 share/frontend/nagvis-js/js/lines.js               |   25 ++++++++++++-------
 share/server/core/mapcfg/default.php               |    8 ++++++
 6 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 903a779..abddf0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,8 @@ Core
     backend to be able to show a bit more details.
   * Using [service_description] as default value for label_text attribute
   * Using z=5 for textboxes and z=1 for shapes again as default values
+  * Added new config option line_label_y_offset to configure the label offset
+    used in weathermap lines which show percentage and absolute bandwidth 
labels
 
 Frontend
   * Sorting maps by alias in header menu now
diff --git a/docs/en_US/map_config_format_description.html 
b/docs/en_US/map_config_format_description.html
index 23a98e6..3d85fed 100644
--- a/docs/en_US/map_config_format_description.html
+++ b/docs/en_US/map_config_format_description.html
@@ -541,6 +541,13 @@
         </td>
         </tr>
         <tr>
+        <td>line_label_y_offset</td>
+        <td>2</td>
+        <td>This option defines the offset of the labels to the line when 
rendering weathermap lines which show percentage
+        and absolute bandwidth labels. <font color="#ff0000">(New in 
1.6)</font>
+        </td>
+        </tr>
+        <tr>
         <td>line_weather_colors</td><td>inherited (<a 
href="#global">global</a>)</td><td>This defines the colors of weathermap colors 
in the different percentage levels. For example above 10% load it will be 
colored #8c00ff. <font color="#ff0000">(New in 1.6)</font></td>
         </tr>
         <tr>
diff --git a/share/frontend/nagvis-js/js/NagVisLine.js 
b/share/frontend/nagvis-js/js/NagVisLine.js
index 19b6d0d..a9eb88e 100644
--- a/share/frontend/nagvis-js/js/NagVisLine.js
+++ b/share/frontend/nagvis-js/js/NagVisLine.js
@@ -119,7 +119,8 @@ var NagVisLine = NagVisStatelessObject.extend({
         drawNagVisLine(this.conf.object_id, this.conf.line_type, cuts, x, y,
                        this.conf.z, width, colorFill, null, null, colorBorder,
                        this.needsLineHoverArea(),
-                       (this.conf.line_label_show && this.conf.line_label_show 
=== '1'));
+                       (this.conf.line_label_show && this.conf.line_label_show 
=== '1'),
+                       this.conf.line_label_y_offset);
     },
 
     remove: function () {
diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js 
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index 88b59ee..2724345 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -606,7 +606,8 @@ var NagVisStatefulObject = NagVisObject.extend({
         drawNagVisLine(this.conf.object_id, this.conf.line_type, cuts, x, y,
                        this.conf.z, width, colorFill, colorFill2, setPerfdata, 
colorBorder,
                        this.needsLineHoverArea(),
-                       (this.conf.line_label_show && this.conf.line_label_show 
=== '1'));
+                       (this.conf.line_label_show && this.conf.line_label_show 
=== '1'),
+                       this.conf.line_label_y_offset);
     },
 
     /**
diff --git a/share/frontend/nagvis-js/js/lines.js 
b/share/frontend/nagvis-js/js/lines.js
index 0e39ae7..db9cabd 100644
--- a/share/frontend/nagvis-js/js/lines.js
+++ b/share/frontend/nagvis-js/js/lines.js
@@ -141,20 +141,23 @@ function drawPolygonBasedObject(objectId, num, xCoord, 
yCoord, z, colorFill, col
     oCanvas = null;
 }
 
-function drawLabel(objectId, num, lineType, lx, ly, z, perfdataA, perfdataB) {
+function drawLabel(objectId, num, lineType, lx, ly, z, perfdataA, perfdataB, 
yOffset) {
     var oLinkContainer = document.getElementById(objectId+'-linelink');
 
     labelShift = getLabelShift(perfdataA);
 
+    // Maybe use function to detect the real height in future
+    var labelHeight = 22;
+
     if(lineType == '13') {
         if(oLinkContainer)
-            oLinkContainer.appendChild(drawNagVisTextbox(objectId+'-link'+num, 
'box', '#ffffff', '#000000', (lx-labelShift), (ly-10), z, 'auto', 'auto', '<b>' 
+ perfdataA + '</b>'));
+            oLinkContainer.appendChild(drawNagVisTextbox(objectId+'-link'+num, 
'box', '#ffffff', '#000000', (lx-labelShift), (ly - labelHeight / 2), z, 
'auto', 'auto', '<b>' + perfdataA + '</b>'));
     } else if(lineType == '14') {
-        var label = drawNagVisTextbox(objectId+'-link'+num, 'box', '#ffffff', 
'#000000', (lx-labelShift), (ly-30), z, 'auto', 'auto', '<b>' + perfdataA + 
'</b>');
+        var label = drawNagVisTextbox(objectId+'-link'+num, 'box', '#ffffff', 
'#000000', (lx-labelShift), (ly - labelHeight - yOffset), z, 'auto', 'auto', 
'<b>' + perfdataA + '</b>');
         if(oLinkContainer)
             oLinkContainer.appendChild(label);
         labelShift = getLabelShift(perfdataB);
-        label = drawNagVisTextbox(objectId+'-link'+(num+1), 'box', '#ffffff', 
'#000000', (lx-labelShift), (ly+10), z, 'auto', 'auto', '<b>' + perfdataB + 
'</b>');
+        label = drawNagVisTextbox(objectId+'-link'+(num+1), 'box', '#ffffff', 
'#000000', (lx-labelShift), (ly + yOffset), z, 'auto', 'auto', '<b>' + 
perfdataB + '</b>');
         if(oLinkContainer)
             oLinkContainer.appendChild(label);
         label = null;
@@ -244,7 +247,7 @@ function drawSimpleLine(objectId, num, x1, y1, x2, y2, z, 
w, colorFill, colorBor
 }
 
 // This function is being called by NagVis for drawing the lines
-function drawNagVisLine(objectId, lineType, cuts, x, y, z, width, colorFill, 
colorFill2, perfdata, colorBorder, bLinkArea, bLabelShow) {
+function drawNagVisLine(objectId, lineType, cuts, x, y, z, width, colorFill, 
colorFill2, perfdata, colorBorder, bLinkArea, bLabelShow, yOffset) {
     // Convert all coords to int
     for(var i = 0; i < x.length; i++) {
         x[i] = parseInt(x[i], 10);
@@ -333,6 +336,10 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, z, 
width, colorFill, col
                 var xMid = x[1];
                 var yMid = y[1];
             }
+
+            // Take the configured line width into account
+            yOffset = yOffset + width / 2;
+
             // perfdataA contains the percentage info
             // perfdataB contains the bandwith info
             if(isset(perfdata[0]) && isset(perfdata[0][1]) && 
isset(perfdata[0][2]))
@@ -340,7 +347,7 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, z, 
width, colorFill, col
             if(isset(perfdata[2]) && isset(perfdata[2][1]) && 
isset(perfdata[2][2]))
                 perfdataB = perfdata[2][1] + perfdata[2][2];
             drawArrow(objectId, 1, xStart, yStart, xMid, yMid, z, width, 
colorFill, colorBorder);
-            drawLinkOrLabel(objectId, 1, lineType, middle(xStart, xMid, 
cutOut), middle(yStart, yMid, cutOut), z, perfdataA, perfdataB, bLinkArea, 
bLabelShow);
+            drawLinkOrLabel(objectId, 1, lineType, middle(xStart, xMid, 
cutOut), middle(yStart, yMid, cutOut), z, perfdataA, perfdataB, bLinkArea, 
bLabelShow, yOffset);
 
             if(isset(perfdata[1]) && isset(perfdata[1][1]) && 
isset(perfdata[1][2]))
                 perfdataA = perfdata[1][1] + perfdata[1][2];
@@ -348,7 +355,7 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, z, 
width, colorFill, col
                 perfdataB = perfdata[3][1] + perfdata[3][2];
            // Needs to be num = 3 because drawLinkOrLabel() call above 
consumes two ids
             drawArrow(objectId, 3, xEnd, yEnd, xMid, yMid, z, width, 
colorFill2, colorBorder);
-            drawLinkOrLabel(objectId, 3, lineType, middle(xEnd, xMid, cutIn), 
middle(yEnd, yMid, cutIn), z, perfdataA, perfdataB, bLinkArea, bLabelShow);
+            drawLinkOrLabel(objectId, 3, lineType, middle(xEnd, xMid, cutIn), 
middle(yEnd, yMid, cutIn), z, perfdataA, perfdataB, bLinkArea, bLabelShow, 
yOffset);
         break;
         default:
             // Unknown
@@ -356,11 +363,11 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, 
z, width, colorFill, col
     }
 }
 
-function drawLinkOrLabel(objectId, num, lineType, x, y, z, perfdataA, 
perfdataB, bLinkArea, bLabelShow) {
+function drawLinkOrLabel(objectId, num, lineType, x, y, z, perfdataA, 
perfdataB, bLinkArea, bLabelShow, yOffset) {
     // First try to create the labels (For weathermap lines only atm) and if 
none
     // should be shown try to create link a link area for the line.
     if(bLabelShow && (lineType == 13 || lineType == 14))
-        drawLabel(objectId, num, lineType, x, y, z, perfdataA, perfdataB);
+        drawLabel(objectId, num, lineType, x, y, z, perfdataA, perfdataB, 
yOffset);
     else if(bLinkArea)
         drawLinkArea(objectId, num, x, y, z);
 }
diff --git a/share/server/core/mapcfg/default.php 
b/share/server/core/mapcfg/default.php
index 02210fc..f2f7fd6 100644
--- a/share/server/core/mapcfg/default.php
+++ b/share/server/core/mapcfg/default.php
@@ -472,6 +472,13 @@ $mapConfigVars = Array(
         'depends_on'    => 'view_type',
         'depends_value' => 'line'
     ),
+    'line_label_y_offset' => Array(
+        'must'          => 0,
+        'default'       => 2,
+        'match'         => MATCH_INTEGER,
+        'depends_on'    => 'view_type',
+        'depends_value' => 'line',
+    ),
     'line_width' => Array(
         'must' => 0,
         'default' => '3',
@@ -959,6 +966,7 @@ $mapConfigVarMap['service'] = Array(
     'line_label_show' => null,
     'line_label_pos_in' => null,
     'line_label_pos_out' => null,
+    'line_label_y_offset' => null,
     'line_width' => null,
     'line_weather_colors' => null,
     'gadget_url' => null,


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to