Module: check_mk
Branch: master
Commit: 3632ce3386aa35da1f3293ddeb61867282de80f5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3632ce3386aa35…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Feb 24 09:36:54 2017 +0100
Combined graphs: use different color shades for stacked representation
Change-Id: I98c2a16db615ef592ebd9ea9fdc2b30dfef832e6
---
ZUTUN.graphing | 7 -------
web/htdocs/metrics.py | 13 +++++++++++++
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/ZUTUN.graphing b/ZUTUN.graphing
index 0ea3326..2aebcf3 100644
--- a/ZUTUN.graphing
+++ b/ZUTUN.graphing
@@ -1,10 +1,3 @@
-[1] Farbabstufungen "stacked".
- "stacked": Pro Farbe zwei Schattierungen. Bei den hellen
- Farben eine dunklere. Bei den dunklen Farben eine hellere.
- Es gibt schon Funktionen, um eine Farbe dunkler bzw. heller
- zu machen.
-
-
[3] au: Implementierung von "Average": einfach die kleine Funktion
au: schreiben, die auch None korrekt berücksichtig. Dann
au: im Graphdesigner das Average auch einbauen.
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 37b04dd..232fe39 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -334,6 +334,19 @@ def lighten_color(rgb, v):
return tuple([ lighten(x, v) for x in rgb ])
+def fade_color(rgb, v):
+ gray = rgb_to_gray(rgb)
+ if gray > 0.5:
+ return darken_color(rgb, v)
+ else:
+ return lighten_color(rgb, v)
+
+
+def rgb_to_gray(rgb):
+ r, g, b = rgb
+ return 0.21 * r + 0.72 * g + 0.07 * b
+
+
def mix_colors(a, b):
return tuple([
(ca + cb) / 2.0