diff --git a/.gitignore b/.gitignore index 80bdfe77..1264f053 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ build/ dist/ .uptodate /.env +.venv test-results/junit-*.xml /.cache .ensure-* diff --git a/grafanalib/core.py b/grafanalib/core.py index 79849fea..cadb536a 100644 --- a/grafanalib/core.py +++ b/grafanalib/core.py @@ -2844,6 +2844,42 @@ def to_json_data(self): } ) +@attr.s +class StatSpecialMapping(object): + """ + Generates json structure for special value mapping item for the StatPanel: + + :param text: String that will replace input value + :param match: Special value to look for + Possible values: null, nan, null+nan, true, false, empty + :param color: How to color the text if mapping occurs + :param index: index + """ + + text = attr.ib() + match = attr.ib(default='', validator=in_([ + 'null', + 'nan', + 'null+nan', + 'true', + 'false', + 'empty' + ])) + color = attr.ib(default='', validator=instance_of(str)) + index = attr.ib(default=None) + + def to_json_data(self): + return { + 'options': { + 'match': self.match, + 'result': { + 'color': self.color, + 'index': self.index, + 'text': self.text + } + }, + 'type': 'special' + } @attr.s class StatValueMappingItem(object):