Browse Source

flake 8

pull/329/head
Nicolas Bonfante 9 years ago
parent
commit
91a6ac2324
  1. 2
      pygal/config.py
  2. 17
      pygal/graph/gauge.py
  3. 3
      pygal/util.py

2
pygal/config.py

@ -262,7 +262,7 @@ class Config(CommonConfig):
"Clockwise", "Clockwise",
"Set to True to make the gauge clockwise." "Set to True to make the gauge clockwise."
) )
title = Key( title = Key(
None, str, "Look", None, str, "Look",
"Graph title.", "Leave it to None to disable title.") "Graph title.", "Leave it to None to disable title.")

17
pygal/graph/gauge.py

@ -46,10 +46,10 @@ class Gauge(Graph):
self._box) self._box)
def clockwiser(self, point): def clockwiser(self, point):
x_0, _ = self.view((0,90)) x_0, _ = self.view((0, 90))
new_x = 2*x_0 - point[0] new_x = 2*x_0 - point[0]
return (new_x, point[1]) return (new_x, point[1])
def needle(self, serie): def needle(self, serie):
"""Draw a needle for each value""" """Draw a needle for each value"""
serie_node = self.svg.serie(serie) serie_node = self.svg.serie(serie)
@ -57,7 +57,7 @@ class Gauge(Graph):
if theta is None: if theta is None:
continue continue
def point(x, y): def point(x, y):
if self.clockwise: if self.clockwise:
transform = compose(self.clockwiser, self.view) transform = compose(self.clockwiser, self.view)
else: else:
@ -85,7 +85,7 @@ class Gauge(Graph):
w = min(w, self._min - self._min * 10 ** -10) w = min(w, self._min - self._min * 10 ** -10)
sweep_flag = '0' if self.clockwise else '1' sweep_flag = '0' if self.clockwise else '1'
alter( alter(
self.svg.node( self.svg.node(
gauges, 'path', d='M %s L %s A %s 1 0 %s %s Z' % ( gauges, 'path', d='M %s L %s A %s 1 0 %s %s Z' % (
@ -101,7 +101,7 @@ class Gauge(Graph):
x, y = self.view((.75, theta)) x, y = self.view((.75, theta))
if self.clockwise: if self.clockwise:
x, y = self.clockwiser((x, y)) x, y = self.clockwiser((x, y))
self._tooltip_data( self._tooltip_data(
gauges, val, x, y, gauges, val, x, y,
xlabel=self._get_x_label(i)) xlabel=self._get_x_label(i))
@ -111,15 +111,13 @@ class Gauge(Graph):
"""Override y axis to plot a polar axis""" """Override y axis to plot a polar axis"""
axis = self.svg.node(self.nodes['plot'], class_="axis x gauge") axis = self.svg.node(self.nodes['plot'], class_="axis x gauge")
liste_y_labels = self._y_labels
if self.clockwise: if self.clockwise:
for i in range(int(len(self._y_labels)/2)): for i in range(int(len(self._y_labels)/2)):
(label_1, theta_1) = self._y_labels[i] (label_1, theta_1) = self._y_labels[i]
(label_2, theta_2) = self._y_labels[len(self._y_labels)-i-1] (label_2, theta_2) = self._y_labels[len(self._y_labels)-i-1]
temp_theta = theta_2 temp_theta = theta_2
self._y_labels[len(self._y_labels)-i-1] = (label_2, theta_1) self._y_labels[len(self._y_labels)-i-1] = (label_2, theta_1)
self._y_labels[i] = (label_1, temp_theta) self._y_labels[i] = (label_1, temp_theta)
for i, (label, theta) in enumerate(self._y_labels): for i, (label, theta) in enumerate(self._y_labels):
guides = self.svg.node(axis, class_='guides') guides = self.svg.node(axis, class_='guides')
@ -175,7 +173,7 @@ class Gauge(Graph):
self.min_, self.max_, self.logarithmic, self.min_, self.max_, self.logarithmic,
self.order_min, self.min_scale, self.max_scale self.order_min, self.min_scale, self.max_scale
) )
if self.y_labels: if self.y_labels:
self._y_labels = [] self._y_labels = []
for i, y_label in enumerate(self.y_labels): for i, y_label in enumerate(self.y_labels):
@ -198,7 +196,6 @@ class Gauge(Graph):
else: else:
self._y_labels = list(zip(map(self._y_format, y_pos), y_pos)) self._y_labels = list(zip(map(self._y_format, y_pos), y_pos))
def _plot(self): def _plot(self):
"""Plot all needles""" """Plot all needles"""
for serie in self.series: for serie in self.series:

3
pygal/util.py

@ -383,6 +383,3 @@ def merge(dict1, dict2):
dict1[key] = mergextend(val, dict1.get(key, ())) dict1[key] = mergextend(val, dict1.get(key, ()))
else: else:
dict1[key] = val dict1[key] = val
def compose(f, g):
return lambda x: f(g(x))

Loading…
Cancel
Save