Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main add graph unit #632

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changelog
==================

* 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 @@ -2059,7 +2059,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 @@ -2093,6 +2093,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 @@ -2112,6 +2113,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
Loading