Browse Source

Fix new codestyle

pull/339/head
Florian Mounier 8 years ago
parent
commit
4ff6debb01
  1. 20
      pygal/graph/box.py
  2. 9
      pygal/graph/graph.py
  3. 2
      pygal/graph/line.py
  4. 2
      pygal/graph/pie.py
  5. 18
      pygal/graph/solidgauge.py
  6. 6
      pygal/svg.py
  7. 4
      pygal/test/test_config.py

20
pygal/graph/box.py

@ -49,8 +49,8 @@ class Box(Graph):
"""
if self.box_mode == "extremes":
return (
'Min: %s\nQ1 : %s\nQ2 : %s\nQ3 : %s\nMax: %s' %
tuple(map(self._y_format, serie.points[1:6])))
'Min: %s\nQ1 : %s\nQ2 : %s\nQ3 : %s\nMax: %s' % tuple(
map(self._y_format, serie.points[1:6])))
elif self.box_mode in ["tukey", "stdev", "pstdev"]:
return (
'Min: %s\nLower Whisker: %s\nQ1: %s\nQ2: %s\nQ3: %s\n'
@ -166,7 +166,7 @@ class Box(Graph):
alter(self.svg.node(
parent_node,
tag='circle',
cx=left_edge+width/2,
cx=left_edge + width / 2,
cy=self.view.y(o),
r=3,
class_='subtle-fill reactive tooltip-trigger'), metadata)
@ -241,12 +241,12 @@ class Box(Graph):
q3 = s[0]
elif n % 4 == 1: # n is of form 4n + 1 where n >= 1
m = (n - 1) // 4
q1 = 0.25 * s[m-1] + 0.75 * s[m]
q3 = 0.75 * s[3*m] + 0.25 * s[3*m+1]
q1 = 0.25 * s[m - 1] + 0.75 * s[m]
q3 = 0.75 * s[3 * m] + 0.25 * s[3 * m + 1]
else: # n is of form 4n + 3 where n >= 1
m = (n - 3) // 4
q1 = 0.75 * s[m] + 0.25 * s[m+1]
q3 = 0.25 * s[3*m+1] + 0.75 * s[3*m+2]
q1 = 0.75 * s[m] + 0.25 * s[m + 1]
q3 = 0.25 * s[3 * m + 1] + 0.75 * s[3 * m + 2]
iqr = q3 - q1
min_s = s[0]
@ -261,7 +261,7 @@ class Box(Graph):
b0 = bisect_left(s, q1 - 1.5 * iqr)
b4 = bisect_right(s, q3 + 1.5 * iqr)
q0 = s[b0]
q4 = s[b4-1]
q4 = s[b4 - 1]
outliers = s[:b0] + s[b4:]
elif mode == 'stdev':
# one standard deviation above and below the mean of the data
@ -269,7 +269,7 @@ class Box(Graph):
b0 = bisect_left(s, q2 - sd)
b4 = bisect_right(s, q2 + sd)
q0 = s[b0]
q4 = s[b4-1]
q4 = s[b4 - 1]
outliers = s[:b0] + s[b4:]
elif mode == 'pstdev':
# one population standard deviation above and below
@ -278,7 +278,7 @@ class Box(Graph):
b0 = bisect_left(s, q2 - sdp)
b4 = bisect_right(s, q2 + sdp)
q0 = s[b0]
q4 = s[b4-1]
q4 = s[b4 - 1]
outliers = s[:b0] + s[b4:]
elif mode == '1.5IQR':
# 1.5IQR mode

9
pygal/graph/graph.py

@ -893,8 +893,8 @@ class Graph(PublicApi):
self._y_labels_major = []
def add_squares(self, squares):
x_lines = squares[0]-1
y_lines = squares[1]-1
x_lines = squares[0] - 1
y_lines = squares[1] - 1
_current_x = 0
_current_y = 0
@ -905,7 +905,8 @@ class Graph(PublicApi):
self.nodes['plot'], 'path',
class_='bg-lines',
d='M%s %s L%s %s' % (
_current_x, 0, _current_x, self.height-self.margin_box.y))
_current_x, 0, _current_x,
self.height - self.margin_box.y))
for line in range(y_lines):
_current_y += (self.height - self.margin_box.y) / squares[1]
@ -913,7 +914,7 @@ class Graph(PublicApi):
self.nodes['plot'], 'path',
class_='bg-lines',
d='M%s %s L%s %s' % (
0, _current_y, self.width-self.margin_box.x, _current_y))
0, _current_y, self.width - self.margin_box.x, _current_y))
return ((self.width - self.margin_box.x) / squares[0],
(self.height - self.margin_box.y) / squares[1])

2
pygal/graph/line.py

@ -63,7 +63,7 @@ class Line(Graph):
# Check to see if the data has been padded with "none's"
# Fill doesn't work correctly otherwise
end = len(values)-1
end = len(values) - 1
while end > 0:
x, y = values[end]
if self.missing_value_fill_truncation == "either":

2
pygal/graph/pie.py

@ -97,7 +97,7 @@ class Pie(Graph):
if total == 0:
return
if self.half_pie:
current_angle = 3*pi/2
current_angle = 3 * pi / 2
else:
current_angle = 0

18
pygal/graph/solidgauge.py

@ -36,20 +36,24 @@ class SolidGauge(Graph):
def gaugify(self, serie, squares, sq_dimensions, current_square):
serie_node = self.svg.serie(serie)
if self.half_pie:
start_angle = 3*pi/2
start_angle = 3 * pi / 2
center = (
(current_square[1]*sq_dimensions[0]) - (sq_dimensions[0] / 2.),
(current_square[0]*sq_dimensions[1]) - (sq_dimensions[1] / 4))
(current_square[1] * sq_dimensions[0]) - (
sq_dimensions[0] / 2.),
(current_square[0] * sq_dimensions[1]) - (
sq_dimensions[1] / 4))
end_angle = pi / 2
else:
start_angle = 0
center = (
(current_square[1]*sq_dimensions[0]) - (sq_dimensions[0] / 2.),
(current_square[0]*sq_dimensions[1]) - (sq_dimensions[1] / 2.))
(current_square[1] * sq_dimensions[0]) - (
sq_dimensions[0] / 2.),
(current_square[0] * sq_dimensions[1]) - (
sq_dimensions[1] / 2.))
end_angle = 2 * pi
max_value = serie.metadata.get(0, {}).get('max_value', 100)
radius = min([sq_dimensions[0]/2, sq_dimensions[1]/2]) * .9
radius = min([sq_dimensions[0] / 2, sq_dimensions[1] / 2]) * .9
small_radius = radius * serie.inner_radius
self.svg.gauge_background(
@ -128,7 +132,7 @@ class SolidGauge(Graph):
_x, _y = 2, 3
if abs(_x - _y) > 2:
_sq = 3
while (_x * _y)-1 < len(self.series):
while (_x * _y) - 1 < len(self.series):
_x, _y = _sq, _sq
_sq += 1
return (_x, _y)

6
pygal/svg.py

@ -319,18 +319,18 @@ class Svg(object):
coord_diff(
center,
coord_project(
radius-(radius-small_radius)/2, start_angle)),
radius - (radius - small_radius) / 2, start_angle)),
coord_diff(
center,
coord_project(
radius-(radius-small_radius)/2, end_angle))]
radius - (radius - small_radius) / 2, end_angle))]
pos = 0
for i in begin_end:
self.node(
serie_node['plot'], 'text',
class_='y-{} bound reactive'.format(pos),
x=i[0],
y=i[1]+10,
y=i[1] + 10,
attrib={'text-anchor': 'middle'}
).text = '{}'.format(0 if pos == 0 else max_value)
pos += 1

4
pygal/test/test_config.py

@ -540,8 +540,8 @@ def test_formatters(Chart):
"""Test custom formatters"""
if Chart._dual or Chart == Box:
return
chart = Chart(formatter=lambda x, chart, serie: '%s%s$' % (
x, serie.title))
chart = Chart(
formatter=lambda x, chart, serie: '%s%s$' % (x, serie.title))
chart.add('_a', [1, 2, {'value': 3, 'formatter': lambda x: u('%s¥') % x}])
chart.add('_b', [4, 5, 6], formatter=lambda x: u('%s') % x)
chart.x_labels = [2, 4, 6]

Loading…
Cancel
Save