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

Extend GaugePanel options #668

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ x.x.x ?
* Fix mappings for Table
* Added support for AWS Cross-Account in CloudwatchMetricsTarget
* Added `LokiTarget`
* Added `color`, `fieldMinMax`, and `thresholdType` option for `GaugePanel`

0.7.1 2024-01-12
================
Expand Down
8 changes: 8 additions & 0 deletions grafanalib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3452,8 +3452,10 @@ class GaugePanel(Panel):

:param allValue: If All values should be shown or a Calculation
:param calc: Calculation to perform on metrics
:param color: color mode
:param dataLinks: list of data links hooked to datapoints on the graph
:param decimals: override automatic decimal precision for legend/tooltips
:param fieldMinMax: force disable/enable min max values
:param format: defines value units
:param labels: option to show gauge level labels
:param limit: limit of number of values to show when not Calculating
Expand All @@ -3463,15 +3465,18 @@ class GaugePanel(Panel):
:param thresholdLabel: label for gauge. Template Variables:
"$__series_namei" "$__field_name" "$__cell_{N} / $__calc"
:param thresholdMarkers: option to show marker of level on gauge
:param thresholdType: threshold mode
: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))
calc = attr.ib(default=GAUGE_CALC_MEAN)
color = attr.ib(default=None)
dataLinks = attr.ib(default=attr.Factory(list))
decimals = attr.ib(default=None)
fieldMinMax = attr.ib(default=None)
format = attr.ib(default='none')
label = attr.ib(default=None)
limit = attr.ib(default=None)
Expand All @@ -3480,6 +3485,7 @@ class GaugePanel(Panel):
rangeMaps = attr.ib(default=attr.Factory(list))
thresholdLabels = attr.ib(default=False, validator=instance_of(bool))
thresholdMarkers = attr.ib(default=True, validator=instance_of(bool))
thresholdType = attr.ib(default='absolute')
michaelgov-ctrl marked this conversation as resolved.
Show resolved Hide resolved
thresholds = attr.ib(
default=attr.Factory(
lambda: [
Expand All @@ -3498,7 +3504,9 @@ def to_json_data(self):
'fieldConfig': {
'defaults': {
'calcs': [self.calc],
'color': self.color,
'decimals': self.decimals,
'fieldMinMax': self.fieldMinMax,
'max': self.max,
'min': self.min,
'title': self.label,
Expand Down