From 4178ca1508dd25f959ea1e115712e8bbd50141cc Mon Sep 17 00:00:00 2001 From: Sachin Panayil Date: Mon, 4 Nov 2024 11:01:10 -0500 Subject: [PATCH] created a reversible graph Signed-off-by: Sachin Panayil linting Signed-off-by: Sachin Panayil --- pygal/graph/gauge.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pygal/graph/gauge.py b/pygal/graph/gauge.py index 91de4894..65f51588 100644 --- a/pygal/graph/gauge.py +++ b/pygal/graph/gauge.py @@ -28,6 +28,11 @@ class Gauge(Graph): 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 +137,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