From 9648516c08d6aa695b04e25e95a939a677a85f1d Mon Sep 17 00:00:00 2001 From: Vasily Sviridov Date: Sat, 19 Jul 2025 17:26:00 +0300 Subject: [PATCH 1/2] feat core: add tooltip params hideZeros --- grafanalib/core.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/grafanalib/core.py b/grafanalib/core.py index 8e7362eb..b36fbf20 100644 --- a/grafanalib/core.py +++ b/grafanalib/core.py @@ -2294,6 +2294,7 @@ class TimeSeries(Panel): single (Default), multi, none :param tooltipSort: To sort the tooltips none (Default), asc, desc + :param tooltipHideZeros: Controls the hideZeros of tooltips :param unit: units :param thresholdsStyleMode: thresholds style mode off (Default), area, line, line+area :param valueMin: Minimum value for Panel @@ -2352,6 +2353,7 @@ class TimeSeries(Panel): stacking = attr.ib(factory=dict, validator=instance_of(dict)) tooltipMode = attr.ib(default='single', validator=instance_of(str)) tooltipSort = attr.ib(default='none', validator=instance_of(str)) + tooltipHideZeros = attr.ib(default=False, validator=instance_of(bool)) unit = attr.ib(default='', validator=instance_of(str)) thresholdsStyleMode = attr.ib(default='off', validator=instance_of(str)) @@ -2413,7 +2415,8 @@ def to_json_data(self): }, 'tooltip': { 'mode': self.tooltipMode, - 'sort': self.tooltipSort + 'sort': self.tooltipSort, + 'hideZeros': self.tooltipHideZeros } }, 'type': TIMESERIES_TYPE, @@ -3864,6 +3867,7 @@ class PieChartv2(Panel): single (Default), multi, none :param tooltipSort: To sort the tooltips none (Default), asc, desc + :param tooltipHideZeros: Controls the hideZeros of tooltips :param unit: units """ @@ -3880,6 +3884,7 @@ class PieChartv2(Panel): reduceOptionsValues = attr.ib(default=False, validator=instance_of(bool)) tooltipMode = attr.ib(default='single', validator=instance_of(str)) tooltipSort = attr.ib(default='none', validator=instance_of(str)) + tooltipHideZeros = attr.ib(default=False, validator=instance_of(bool)) unit = attr.ib(default='', validator=instance_of(str)) def to_json_data(self): @@ -3905,7 +3910,8 @@ def to_json_data(self): 'pieType': self.pieType, 'tooltip': { 'mode': self.tooltipMode, - 'sort': self.tooltipSort + 'sort': self.tooltipSort, + 'hideZeros': self.tooltipHideZeros }, 'legend': { 'displayMode': self.legendDisplayMode, @@ -4456,6 +4462,7 @@ class BarChart(Panel): :param barRadius: Controls the radius of the bars :param toolTipMode: Controls the style of tooltips :param toolTipSort: Controls the sort order of tooltips, when toolTipMode is 'All' + :param tooltipHideZeros: Controls the hideZeros of tooltips :param showLegend: Controls the visibility of legends :param legendDisplayMode: Controls the style of legends, if they are shown. :param legendPlacement: Controls the placement of legends, if they are shown @@ -4488,6 +4495,7 @@ class BarChart(Panel): barRadius = attr.ib(default=0.0, validator=instance_of(float)) tooltipMode = attr.ib(default='single', validator=instance_of(str)) tooltipSort = attr.ib(default='none', validator=instance_of(str)) + tooltipHideZeros = attr.ib(default=False, validator=instance_of(bool)) showLegend = attr.ib(default=True, validator=instance_of(bool)) legendDisplayMode = attr.ib(default='list', validator=instance_of(str)) legendPlacement = attr.ib(default='bottom', validator=instance_of(str)) @@ -4536,7 +4544,8 @@ def to_json_data(self): 'barRadius': self.barRadius, 'tooltip': { 'mode': self.tooltipMode, - 'sort': self.tooltipSort + 'sort': self.tooltipSort, + 'hideZeros': self.tooltipHideZeros }, 'legend': { 'showLegend': self.showLegend, From 288de5fdcbf181c8a0fc1f0434251aae4f90454a Mon Sep 17 00:00:00 2001 From: Vasily Sviridov Date: Mon, 25 Aug 2025 03:54:18 +0300 Subject: [PATCH 2/2] feat docs: add tooltipHideZeros to changelog --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ea76aedc..2819c8c7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,7 @@ Changelog x.x.x ? ======= +* Added `tooltipHideZeros` parameter to TimeSeries and BarChart panels * Add `QueryMode` parameter in CloudwatchMetricsTarget * Added support `alias` via the `legendFormat` option for `Target` * Added `neutral` option for `GaugePanel` (supported by Grafana 9.3.0 - https://github.com/grafana/grafana/discussions/38273)