From 36682378fca187081ff47801c9262eb1364c31e4 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 7 Jan 2016 14:07:26 -0800 Subject: [PATCH] Add support for nullPointMode Change-Id: Iedc5eec1ad06498a191b342cc70ce4424741e16f --- grafana_dashboards/schema/panel/graph.py | 3 ++ tests/schema/fixtures/dashboard-0011.json | 39 +++++++++++++++++++++++ tests/schema/fixtures/dashboard-0011.yaml | 11 +++++++ 3 files changed, 53 insertions(+) create mode 100644 tests/schema/fixtures/dashboard-0011.json create mode 100644 tests/schema/fixtures/dashboard-0011.yaml diff --git a/grafana_dashboards/schema/panel/graph.py b/grafana_dashboards/schema/panel/graph.py index c24f235..f102476 100644 --- a/grafana_dashboards/schema/panel/graph.py +++ b/grafana_dashboards/schema/panel/graph.py @@ -84,6 +84,8 @@ class Graph(Base): y_formats = [y_format] + null_point_modes = v.Any('connected', 'null', 'null as zero') + graph = { v.Required('bars', default=False): v.All(bool), v.Required('fill', default=1): v.All(int), @@ -97,6 +99,7 @@ class Graph(Base): v.Required('targets', default=[]): v.All(list), 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)), diff --git a/tests/schema/fixtures/dashboard-0011.json b/tests/schema/fixtures/dashboard-0011.json new file mode 100644 index 0000000..41b417e --- /dev/null +++ b/tests/schema/fixtures/dashboard-0011.json @@ -0,0 +1,39 @@ +{ + "dashboard": { + "new-dashboard": { + "rows": [ + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "bars": false, + "editable": true, + "error": false, + "fill": 1, + "lines": true, + "linewidth": 2, + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [], + "title": "no title (click here)", + "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-0011.yaml b/tests/schema/fixtures/dashboard-0011.yaml new file mode 100644 index 0000000..fbb152c --- /dev/null +++ b/tests/schema/fixtures/dashboard-0011.yaml @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- + +dashboard: + title: New dashboard + rows: + - title: New row + height: 250px + panels: + - title: no title (click here) + type: graph + nullPointMode: null as zero