Skip to content

Commit 4178ca1

Browse files
created a reversible graph
Signed-off-by: Sachin Panayil <sachinpanayil01@gmail.com> linting Signed-off-by: Sachin Panayil <sachinpanayil01@gmail.com>
1 parent b7c8f2a commit 4178ca1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pygal/graph/gauge.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class Gauge(Graph):
2828

2929
needle_width = 1 / 20
3030

31+
def __init__(self, *args, reverse_direction=False, **kwargs):
32+
"""Initialize the gauge with direction configuration"""
33+
super(Gauge, self).__init__(*args, **kwargs)
34+
self.reverse_direction = reverse_direction
35+
3136
def _set_view(self):
3237
"""Assign a view to current graph"""
3338
if self.logarithmic:
@@ -132,7 +137,10 @@ def _compute(self):
132137
self.min_ -= 1
133138
self.max_ += 1
134139

135-
self._box.set_polar_box(0, 1, self.min_, self.max_)
140+
if self.reverse_direction:
141+
self._box.set_polar_box(0, 1, self.max_, self.min_)
142+
else:
143+
self._box.set_polar_box(0, 1, self.min_, self.max_)
136144

137145
def _compute_x_labels(self):
138146
pass

0 commit comments

Comments
 (0)