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

Neutral option for GaugePanel #649

Merged
merged 6 commits into from
Jul 16, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changelog
x.x.x ?
=======

* Added `neutral` option for `GaugePanel` (supported by Grafana 9.3.0 - https://github.com/grafana/grafana/discussions/38273)
* Added support `alias` via the `legendFormat` option for `Target`
* **Breaking change:** Fixed spelling errors for temperature units, corrected 'CELSUIS' to 'CELSIUS' and 'FARENHEIT' to 'FAHRENHEIT'.
* Added ``tooltipSort`` parameter to PieChartv2 panel
* Fix mappings for Table
Expand Down
7 changes: 7 additions & 0 deletions grafanalib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ class Target(object):
Metric to show.

:param target: Graphite way to select data
:param legendFormat: Target alias. Prometheus use legendFormat, other like Influx use alias. This set legendFormat as well as alias.
"""

expr = attr.ib(default="")
Expand All @@ -598,6 +599,7 @@ def to_json_data(self):
'interval': self.interval,
'intervalFactor': self.intervalFactor,
'legendFormat': self.legendFormat,
'alias': self.legendFormat,
'metric': self.metric,
'refId': self.refId,
'step': self.step,
Expand Down Expand Up @@ -3463,6 +3465,7 @@ class GaugePanel(Panel):
:param thresholdMarkers: option to show marker of level on gauge
:param thresholds: single stat thresholds
:param valueMaps: the list of value to text mappings
:param neutral: neutral point of gauge, leave empty to use Min as neutral point
"""

allValues = attr.ib(default=False, validator=instance_of(bool))
Expand All @@ -3487,6 +3490,7 @@ class GaugePanel(Panel):
validator=instance_of(list),
)
valueMaps = attr.ib(default=attr.Factory(list))
neutral = attr.ib(default=None)

def to_json_data(self):
return self.panel_json(
Expand All @@ -3504,6 +3508,9 @@ def to_json_data(self):
'mappings': self.valueMaps,
'override': {},
'values': self.allValues,
'custom': {
'neutral': self.neutral,
},
},
'showThresholdLabels': self.thresholdLabels,
'showThresholdMarkers': self.thresholdMarkers,
Expand Down
Loading