diff --git a/grafana_dashboards/schema/panel/graph.py b/grafana_dashboards/schema/panel/graph.py index f102476..1e0b30e 100644 --- a/grafana_dashboards/schema/panel/graph.py +++ b/grafana_dashboards/schema/panel/graph.py @@ -85,23 +85,31 @@ class Graph(Base): y_formats = [y_format] null_point_modes = v.Any('connected', 'null', 'null as zero') + value_types = v.Any('individual', 'cumulative') + + tooltip = { + v.Required('query_as_alias', default=True): v.All(bool), + v.Required('shared', default=True): v.All(bool), + v.Required('value_type', default='cumulative'): v.All(value_types), + } graph = { v.Required('bars', default=False): v.All(bool), v.Required('fill', default=1): v.All(int), + v.Optional('leftYAxisLabel'): v.All(str, v.Length(min=1)), v.Required('lines', default=True): v.All(bool), v.Required('linewidth', default=2): v.All(int), + v.Optional('nullPointMode'): v.All(null_point_modes), v.Required('percentage', default=False): v.All(bool), v.Required('pointradius', default=5): v.All(int), v.Required('points', default=False): v.All(bool), + v.Optional('rightYAxisLabel'): v.All(str, v.Length(min=1)), v.Required('stack', default=False): v.All(bool), v.Required('steppedLine', default=False): v.All(bool), v.Required('targets', default=[]): v.All(list), + v.Optional('tooltip'): v.All(tooltip), v.Required('x-axis', default=True): v.All(bool), v.Required('y-axis', default=True): v.All(bool), - v.Optional('nullPointMode'): v.All(null_point_modes), - 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) diff --git a/tests/schema/fixtures/dashboard-0012.json b/tests/schema/fixtures/dashboard-0012.json new file mode 100644 index 0000000..cde1484 --- /dev/null +++ b/tests/schema/fixtures/dashboard-0012.json @@ -0,0 +1,43 @@ +{ + "dashboard": { + "new-dashboard": { + "rows": [ + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "bars": false, + "editable": true, + "error": false, + "fill": 1, + "lines": true, + "linewidth": 2, + "percentage": false, + "pointradius": 5, + "points": false, + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [], + "title": "no title (click here)", + "tooltip": { + "query_as_alias": true, + "shared": true, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "y-axis": true + } + ], + "showTitle": false, + "title": "New row" + } + ], + "timezone": "utc", + "title": "New dashboard" + } + } +} diff --git a/tests/schema/fixtures/dashboard-0012.yaml b/tests/schema/fixtures/dashboard-0012.yaml new file mode 100644 index 0000000..9b3c88a --- /dev/null +++ b/tests/schema/fixtures/dashboard-0012.yaml @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- + +dashboard: + title: New dashboard + rows: + - title: New row + height: 250px + panels: + - title: no title (click here) + type: graph + tooltip: + value_type: individual