Skip to content

Commit

Permalink
Main add graph unit (#632)
Browse files Browse the repository at this point in the history
* Add the Unit field to Graph Panels

* Update changelog for Graph Panel
  • Loading branch information
padraic-padraic authored Sep 29, 2023
1 parent 1a0a0e8 commit c82a679
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Changelog
.. _`docs`: https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/manage-dashboard-links/#dashboard-links

* Added ...
* Add Unit option for Graph panel
* Added Minimum option for Timeseries
* Added Maximum option for Timeseries
* Added Number of decimals displays option for Timeseries
Expand Down
8 changes: 7 additions & 1 deletion grafanalib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ class Graph(Panel):
:param stack: Each series is stacked on top of another
:param percentage: Available when Stack is selected. Each series is drawn as a percentage of the total of all series
:param thresholds: List of GraphThresholds - Only valid when alert not defined
:param unit: Set Y Axis Unit
"""

alert = attr.ib(default=None)
Expand Down Expand Up @@ -2138,6 +2138,7 @@ class Graph(Panel):
validator=instance_of(Tooltip),
)
thresholds = attr.ib(default=attr.Factory(list))
unit = attr.ib(default='', validator=instance_of(str))
xAxis = attr.ib(default=attr.Factory(XAxis), validator=instance_of(XAxis))
try:
yAxes = attr.ib(
Expand All @@ -2157,6 +2158,11 @@ def to_json_data(self):
'aliasColors': self.aliasColors,
'bars': self.bars,
'error': self.error,
'fieldConfig': {
'defaults': {
'unit': self.unit
},
},
'fill': self.fill,
'grid': self.grid,
'isNew': self.isNew,
Expand Down

0 comments on commit c82a679

Please sign in to comment.