Add valueMaps and rangeMaps support
These allow you to specify custom text instead of displayed values Change-Id: I7e5c6067c0b0d26edc18120283bad30887df0663
This commit is contained in:
parent
60a4c15c9b
commit
e6c7095c6b
@ -47,6 +47,18 @@ class Singlestat(Base):
|
||||
v.Required('thresholdMarkers', default=False): v.All(bool),
|
||||
}
|
||||
|
||||
valuemap = {
|
||||
v.Required('op', default='='): v.Any(str),
|
||||
v.Required('value'): v.Any(int),
|
||||
v.Required('text'): v.Any(str)
|
||||
}
|
||||
|
||||
rangemap = {
|
||||
v.Required('from'): v.Any(int),
|
||||
v.Required('to'): v.Any(int),
|
||||
v.Required('text'): v.Any(str),
|
||||
}
|
||||
|
||||
singlestat = {
|
||||
v.Required('colorBackground', default=False): v.All(bool),
|
||||
v.Required('colorValue', default=False): v.All(bool),
|
||||
@ -76,6 +88,8 @@ class Singlestat(Base):
|
||||
v.Optional('hideTimeOverride'): v.All(bool),
|
||||
v.Optional('timeFrom'): v.All(v.Match(r'[1-9]+[0-9]*[smhdw]')),
|
||||
v.Optional('timeShift'): v.All(v.Match(r'[1-9]+[0-9]*[smhdw]')),
|
||||
v.Optional('valueMaps'): v.All([valuemap]),
|
||||
v.Optional('rangeMaps'): v.All([rangemap]),
|
||||
}
|
||||
singlestat.update(self.base)
|
||||
return v.Schema(singlestat)
|
||||
|
@ -25,6 +25,18 @@
|
||||
"postfixFontSize": "50%",
|
||||
"prefix": "",
|
||||
"prefixFontSize": "50%",
|
||||
"rangeMaps": [
|
||||
{
|
||||
"from": 2,
|
||||
"text": "TWOTHREE",
|
||||
"to": 3
|
||||
},
|
||||
{
|
||||
"from": 4,
|
||||
"text": "FOURFIVE",
|
||||
"to": 5
|
||||
}
|
||||
],
|
||||
"span": 12,
|
||||
"sparkline": {
|
||||
"fillColor": "rgba(31, 118, 189, 0.18)",
|
||||
@ -39,6 +51,18 @@
|
||||
"title": "no title (click here)",
|
||||
"type": "singlestat",
|
||||
"valueFontSize": "80%",
|
||||
"valueMaps": [
|
||||
{
|
||||
"op": "=",
|
||||
"text": "OK",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"op": "=",
|
||||
"text": "NOT OK",
|
||||
"value": 1
|
||||
}
|
||||
],
|
||||
"valueName": "avg"
|
||||
}
|
||||
],
|
||||
|
@ -15,3 +15,15 @@ dashboard:
|
||||
show: true
|
||||
thresholdLabels: false
|
||||
thresholdMarkers: true
|
||||
valueMaps:
|
||||
- value: 0
|
||||
text: 'OK'
|
||||
- value: 1
|
||||
text: 'NOT OK'
|
||||
rangeMaps:
|
||||
- from: 2
|
||||
to: 3
|
||||
text: 'TWOTHREE'
|
||||
- from: 4
|
||||
to: 5
|
||||
text: 'FOURFIVE'
|
||||
|
Loading…
x
Reference in New Issue
Block a user