Module: check_mk
Branch: master
Commit: 918411aac9d0156221485380b73a4ad483b651a3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=918411aac9d015…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed May 9 16:30:57 2012 +0200
Cleanup of implementation of spheres
---
.bugs/684 | 8 ++++++--
web/htdocs/dashboard.py | 37 ++++++++++++++++++++++---------------
2 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/.bugs/684 b/.bugs/684
index 03c489d..d88bc06 100644
--- a/.bugs/684
+++ b/.bugs/684
@@ -1,10 +1,14 @@
Title: Host/Service stastics globe: check scale
Component: multisite
-State: open
+Class: nastiness
+State: done
Date: 2012-05-09 15:10:19
Targetversion: 1.2.0
-Class: nastiness
It seems to me that the sizes of the critical/warning
spheres are too large. Checks this out and maybe fix
it.
+
+2012-05-09 16:30:41: changed state open -> done
+I've checked this out. The scale is really correct. The human
+eye does not realize the exponent here.
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index fa97d32..e4ca77c 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -543,29 +543,36 @@ def render_statistics(pie_id, what, table, filter):
r = 0.0
pie_parts = []
if total > 0:
- # Counter number of non-zero classes
+ # Count number of non-empty classes
num_nonzero = 0
for info, value in pies:
if value > 0:
num_nonzero += 1
- # Each non-zero class gets at least a view pixels of visible thickness
- separator = 0.05 # 5% of radius
- rest_radius = 1 - num_nonzero * separator
-
- # Make sure, that each class that is not zero has at least a certain
- # amount so that it will be visible
- totalpart = 1
- # Loop over classes, begin with red (most inner ball)
- sum_separator = num_nonzero * separator
+ # Each non-zero class gets at least a view pixels of visible thickness.
+ # We reserve that space right now. All computations are done in percent
+ # of the radius.
+ separator = 0.02 # 3% of radius
+ remaining_separatorspace = num_nonzero * separator # space for separators
+ remaining_radius = 1 - remaining_separatorspace # remaining space
+ remaining_part = 1.0 # keep track of remaining part, 1.0 = 100%
+
+ # Loop over classes, begin with most outer sphere. Inner spheres show
+ # worse states and appear larger to the user (which is the reason we
+ # are doing all this stuff in the first place)
for (name, color, viewurl, q), value in pies[::1]:
- part = float(value) / total
- if value > 0 and totalpart > 0:
- radius = sum_separator + rest_radius * totalpart ** (1/3.0)
+ if value > 0 and remaining_part > 0: # skip empty classes
+
+ # compute radius of this sphere *including all inner spheres!* The first
+ # sphere always gets a radius of 1.0, of course.
+ radius = remaining_separatorspace + remaining_radius * (remaining_part **
(1/3.0))
pie_parts.append('chart_pie("%s", %f, %f, %r);' %
(pie_id, pie_right_aspect, radius, color))
pie_parts.append('chart_pie("%s", -%f, %f, %r);' %
(pie_id, pie_left_aspect, radius, color))
- totalpart -= part
- sum_separator -= separator
+
+ # compute relative part of this class
+ part = float(value) / total # ranges from 0 to 1
+ remaining_part -= part
+ remaining_separatorspace -= separator
html.write("</div>")