Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created a Reversible Gauge Graph Option #567

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pygal/graph/gauge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down