[update] added color palette suggested by AM, some visual tweaks
This commit is contained in:
parent
10e2322882
commit
353f073d12
@ -514,7 +514,7 @@ class SurveillanceBot(object):
|
|||||||
|
|
||||||
# write footer with optional logo
|
# write footer with optional logo
|
||||||
logo_file = self.parameters.get('html_logo')
|
logo_file = self.parameters.get('html_logo')
|
||||||
if not os.path.isfile(logo_file):
|
if not os.path.isfile(pjoin(self.outpath_html, logo_file)):
|
||||||
print(f'Specified file {logo_file} not found.')
|
print(f'Specified file {logo_file} not found.')
|
||||||
logo_file = None
|
logo_file = None
|
||||||
|
|
||||||
|
25
utils.py
25
utils.py
@ -1,8 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from functools import partial
|
|
||||||
|
|
||||||
import matplotlib
|
import matplotlib
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
@ -36,7 +34,7 @@ def get_bg_color(check_key, status, dt_thresh=None, hex=False):
|
|||||||
|
|
||||||
|
|
||||||
def get_color(key):
|
def get_color(key):
|
||||||
# some GUI default colors
|
# some old GUI default colors
|
||||||
# colors_dict = {'FAIL': (255, 85, 50, 255),
|
# colors_dict = {'FAIL': (255, 85, 50, 255),
|
||||||
# 'NO DATA': (255, 255, 125, 255),
|
# 'NO DATA': (255, 255, 125, 255),
|
||||||
# 'WARN': (255, 255, 80, 255),
|
# 'WARN': (255, 255, 80, 255),
|
||||||
@ -45,8 +43,8 @@ def get_color(key):
|
|||||||
# 'disc': (255, 160, 40, 255),}
|
# 'disc': (255, 160, 40, 255),}
|
||||||
colors_dict = {'FAIL': (195, 29, 14, 255),
|
colors_dict = {'FAIL': (195, 29, 14, 255),
|
||||||
'NO DATA': (255, 255, 125, 255),
|
'NO DATA': (255, 255, 125, 255),
|
||||||
'WARN': (249, 238, 139, 255),
|
'WARN': (250, 192, 63, 255),
|
||||||
'OK': (179, 219, 153, 255),
|
'OK': (185, 245, 145, 255),
|
||||||
'undefined': (240, 240, 240, 255),
|
'undefined': (240, 240, 240, 255),
|
||||||
'disc': (126, 127, 131, 255), }
|
'disc': (126, 127, 131, 255), }
|
||||||
return colors_dict.get(key)
|
return colors_dict.get(key)
|
||||||
@ -67,16 +65,11 @@ def get_time_delay_color(dt, dt_thresh):
|
|||||||
return get_color('FAIL')
|
return get_color('FAIL')
|
||||||
|
|
||||||
|
|
||||||
def get_warn_color(count):
|
def get_warn_color(count, n_colors=20):
|
||||||
#color = (min([255, 220 + count ** 2]), 255, 80, 255)
|
if count > n_colors:
|
||||||
n_colors = 20
|
count = -1
|
||||||
r = np.linspace(204, 249, n_colors, dtype=int)
|
gradient = np.linspace((240, 245, 110, 255), (250, 192, 63, 255), n_colors, dtype=int)
|
||||||
g = np.linspace(226, 238, n_colors, dtype=int)
|
return tuple(gradient[count])
|
||||||
b = np.linspace(149, 139, n_colors, dtype=int)
|
|
||||||
pad = partial(np.pad, pad_width=(0, 100), mode='edge')
|
|
||||||
r, g, b = map(pad, [r, g, b])
|
|
||||||
color = (r[count], g[count], b[count], 255)
|
|
||||||
return color
|
|
||||||
|
|
||||||
|
|
||||||
def get_mass_color(message):
|
def get_mass_color(message):
|
||||||
@ -252,4 +245,4 @@ def plot_threshold_lines(fig, channel_threshold_list, parameters, **kwargs):
|
|||||||
if isinstance(warn_thresh, str):
|
if isinstance(warn_thresh, str):
|
||||||
warn_thresh = parameters.get('THRESHOLDS').get(warn_thresh)
|
warn_thresh = parameters.get('THRESHOLDS').get(warn_thresh)
|
||||||
if type(warn_thresh in (float, int)):
|
if type(warn_thresh in (float, int)):
|
||||||
ax.axhline(warn_thresh, **kwargs)
|
ax.axhline(warn_thresh, **kwargs)
|
||||||
|
@ -40,11 +40,11 @@ def get_mail_html_header():
|
|||||||
|
|
||||||
|
|
||||||
def init_html_table():
|
def init_html_table():
|
||||||
return '<div id="managerTable" ><table style="width:100%">\n'
|
return '<table style="width:100%">\n'
|
||||||
|
|
||||||
|
|
||||||
def finish_html_table():
|
def finish_html_table():
|
||||||
return '</table></div>\n'
|
return '</table>\n'
|
||||||
|
|
||||||
|
|
||||||
def html_footer(footer_logo=None):
|
def html_footer(footer_logo=None):
|
||||||
@ -79,11 +79,9 @@ def get_html_row(items, html_key='td'):
|
|||||||
if item.get('italic'):
|
if item.get('italic'):
|
||||||
text = '<i>' + text + '</i>'
|
text = '<i>' + text + '</i>'
|
||||||
tooltip = item.get('tooltip')
|
tooltip = item.get('tooltip')
|
||||||
color = item.get('color')
|
|
||||||
# check for black background of headers (shouldnt happen anymore)
|
|
||||||
color = '#e6e6e6' if color == '#000000' else color
|
|
||||||
font_color = item.get('font_color')
|
font_color = item.get('font_color')
|
||||||
hyperlink = item.get('hyperlink')
|
hyperlink = item.get('hyperlink')
|
||||||
|
color = 'transparent' if hyperlink else item.get('color')
|
||||||
text_str = get_html_link(text, hyperlink) if hyperlink else text
|
text_str = get_html_link(text, hyperlink) if hyperlink else text
|
||||||
html_class = item.get('html_class')
|
html_class = item.get('html_class')
|
||||||
class_str = f' class="{html_class}"' if html_class else ''
|
class_str = f' class="{html_class}"' if html_class else ''
|
||||||
|
Loading…
Reference in New Issue
Block a user