Skip to content

Commit

Permalink
created a reversable gauge graph
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Panayil <[email protected]>
  • Loading branch information
sachin-panayil committed Nov 4, 2024
1 parent b7c8f2a commit 32ca105
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pygal/graph/gauge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 32ca105

Please sign in to comment.