Add support for Y axis formats
The list of valid formats is taken from: https://github.com/grafana/grafana/blob/master/public/app/core/utils/kbn.js (grep "value:" in that file). Change-Id: Ibe7317847beba3db3205d759fbf6492e005b128f
This commit is contained in:
parent
ff88ef29e2
commit
17e53a824d
|
@ -1,3 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -20,6 +22,68 @@ from grafana_dashboards.schema.panel.base import Base
|
|||
class Graph(Base):
|
||||
|
||||
def get_schema(self):
|
||||
y_format = v.Any(
|
||||
u'none',
|
||||
u'short',
|
||||
u'percent',
|
||||
u'percentunit',
|
||||
u'humidity',
|
||||
u'ppm',
|
||||
u'dB',
|
||||
u'currencyUSD',
|
||||
u'currencyGBP',
|
||||
u'currencyEUR',
|
||||
u'currencyJPY',
|
||||
u'hertz',
|
||||
u'ns',
|
||||
u'µs',
|
||||
u'ms',
|
||||
u's',
|
||||
u'm',
|
||||
u'h',
|
||||
u'd',
|
||||
u'bits',
|
||||
u'bytes',
|
||||
u'kbytes',
|
||||
u'mbytes',
|
||||
u'gbytes',
|
||||
u'pps',
|
||||
u'bps',
|
||||
u'Bps',
|
||||
u'ops',
|
||||
u'rps',
|
||||
u'wps',
|
||||
u'iops',
|
||||
u'lengthmm',
|
||||
u'lengthm',
|
||||
u'lengthkm',
|
||||
u'lengthmi',
|
||||
u'velocityms',
|
||||
u'velocitykmh',
|
||||
u'velocitymph',
|
||||
u'velocityknot',
|
||||
u'mlitre',
|
||||
u'litre',
|
||||
u'm3',
|
||||
u'watt',
|
||||
u'kwatt',
|
||||
u'watth',
|
||||
u'kwatth',
|
||||
u'joule',
|
||||
u'ev',
|
||||
u'amp',
|
||||
u'volt',
|
||||
u'celsius',
|
||||
u'farenheit',
|
||||
u'kelvin',
|
||||
u'pressurembar',
|
||||
u'pressurehpa',
|
||||
u'pressurehg',
|
||||
u'pressurepsi',
|
||||
)
|
||||
|
||||
y_formats = [y_format]
|
||||
|
||||
graph = {
|
||||
v.Required('bars', default=False): v.All(bool),
|
||||
v.Required('fill', default=1): v.All(int),
|
||||
|
@ -35,6 +99,7 @@ class Graph(Base):
|
|||
v.Required('y-axis', default=True): v.All(bool),
|
||||
v.Optional('leftYAxisLabel'): v.All(str, v.Length(min=1)),
|
||||
v.Optional('rightYAxisLabel'): v.All(str, v.Length(min=1)),
|
||||
v.Optional('y_formats'): v.All(y_formats, v.Length(min=2, max=2)),
|
||||
}
|
||||
graph.update(self.base)
|
||||
return v.Schema(graph)
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"dashboard": {
|
||||
"new-dashboard": {
|
||||
"rows": [
|
||||
{
|
||||
"collapse": false,
|
||||
"editable": true,
|
||||
"height": "250px",
|
||||
"panels": [
|
||||
{
|
||||
"bars": false,
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"fill": 1,
|
||||
"leftYAxisLabel": "left label",
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"rightYAxisLabel": "right label",
|
||||
"span": 12,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [],
|
||||
"title": "no title (click here)",
|
||||
"type": "graph",
|
||||
"x-axis": true,
|
||||
"y-axis": true,
|
||||
"y_formats": [
|
||||
"hertz",
|
||||
"\u00b5s"
|
||||
]
|
||||
}
|
||||
],
|
||||
"showTitle": false,
|
||||
"title": "New row"
|
||||
}
|
||||
],
|
||||
"timezone": "utc",
|
||||
"title": "New dashboard"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
dashboard:
|
||||
title: New dashboard
|
||||
rows:
|
||||
- title: New row
|
||||
height: 250px
|
||||
panels:
|
||||
- title: no title (click here)
|
||||
type: graph
|
||||
leftYAxisLabel: left label
|
||||
rightYAxisLabel: right label
|
||||
y_formats:
|
||||
- hertz
|
||||
- µs
|
Loading…
Reference in New Issue