From 32ca10545fffb9889b3a698b1a42751b5381487b Mon Sep 17 00:00:00 2001 From: Sachin Panayil Date: Mon, 4 Nov 2024 11:01:10 -0500 Subject: [PATCH] created a reversable gauge graph Signed-off-by: Sachin Panayil --- pygal/graph/gauge.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pygal/graph/gauge.py b/pygal/graph/gauge.py index 91de4894..4d3bd76c 100644 --- a/pygal/graph/gauge.py +++ b/pygal/graph/gauge.py @@ -22,12 +22,16 @@ from pygal.util import alter, compute_scale, cut, decorate from pygal.view import PolarThetaLogView, PolarThetaView - class Gauge(Graph): """Gauge graph class""" needle_width = 1 / 20 + def __init__(self, *args, reverse_direction=False, **kwargs): + """Initialize the gauge with direction configuration""" + super(Gauge, self).__init__(*args, **kwargs) + self.reverse_direction = reverse_direction + def _set_view(self): """Assign a view to current graph""" if self.logarithmic: @@ -132,7 +136,10 @@ def _compute(self): self.min_ -= 1 self.max_ += 1 - self._box.set_polar_box(0, 1, self.min_, self.max_) + if self.reverse_direction: + self._box.set_polar_box(0, 1, self.max_, self.min_) + else: + self._box.set_polar_box(0, 1, self.min_, self.max_) def _compute_x_labels(self): pass