Add legend for graphs

Simple support for a legend on graphs.

Change-Id: I3dc96a1463a8e765b9c97fa2fd1550872d7a285f
This commit is contained in:
akrzos 2018-01-02 16:07:52 -05:00
parent fccc26d53b
commit 96cf8f97d4
3 changed files with 108 additions and 0 deletions

View File

@ -84,6 +84,18 @@ class Graph(Base):
y_formats = [y_format]
legend = {
v.Optional('alignAsTable', default=False): v.All(bool),
v.Optional('avg', default=False): v.All(bool),
v.Optional('current', default=False): v.All(bool),
v.Optional('max', default=False): v.All(bool),
v.Optional('min', default=False): v.All(bool),
v.Optional('rightSide', default=False): v.All(bool),
v.Optional('show', default=False): v.All(bool),
v.Optional('total', default=False): v.All(bool),
v.Optional('values', default=False): v.All(bool),
}
null_point_modes = v.Any('connected', 'null', 'null as zero')
value_types = v.Any('individual', 'cumulative')
@ -119,6 +131,7 @@ class Graph(Base):
v.Required('fill', default=1): v.All(int),
v.Optional('hideTimeOverride'): v.All(bool),
v.Optional('leftYAxisLabel'): v.All(str, v.Length(min=1)),
v.Optional('legend'): v.All(legend),
v.Required('lines', default=True): v.All(bool),
v.Required('linewidth', default=2): v.All(int),
v.Optional('nullPointMode'): v.All(null_point_modes),

View File

@ -0,0 +1,68 @@
{
"dashboard": {
"new-dashboard": {
"rows": [
{
"collapse": false,
"editable": true,
"height": "250px",
"panels": [
{
"bars": false,
"datasource": "graphite",
"editable": true,
"error": false,
"fill": 1,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 2,
"percentage": false,
"pointradius": 5,
"points": false,
"span": 12,
"stack": false,
"steppedLine": false,
"targets": [
{
"target": "$hostname.Cpu.cpu_prct_used"
}
],
"title": "no title (click here)",
"type": "graph",
"x-axis": true,
"y-axis": true
}
],
"showTitle": false,
"title": "New row"
}
],
"templating": {
"enabled": true,
"list": [
{
"datasource": "graphite",
"includeAll": false,
"multi": false,
"name": "hostname",
"query": "node*",
"refresh": true,
"type": "query"
}
]
},
"timezone": "utc",
"title": "New dashboard"
}
}
}

View File

@ -0,0 +1,27 @@
dashboard:
templating:
- name: hostname
type: query
datasource: graphite
query: node*
refresh: true
title: New dashboard
rows:
- title: New row
height: 250px
panels:
- title: no title (click here)
type: graph
datasource: graphite
targets:
- target: $hostname.Cpu.cpu_prct_used
legend:
alignAsTable: true
avg: true
current: true
max: true
min: true
rightSide: true
show: true
total: false
values: true