Skip to content

Commit

Permalink
Solve Kozea#309 with flake8 constrain
Browse files Browse the repository at this point in the history
  • Loading branch information
qins committed Sep 25, 2016
1 parent f94b031 commit 4b3fc71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
17 changes: 6 additions & 11 deletions pygal/graph/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,9 @@ def line(self, serie, rescale=False):
for i, (x, y) in enumerate(view_values):
if None in (x, y):
continue

#modified
if self.logarithmic:
if points[i][1] == None or points[i][1] <= 0:
continue

if points[i][1] is None or points[i][1] <= 0:
continue
if (serie.show_only_major_dots and
self.x_labels and i < len(self.x_labels) and
self.x_labels[i] not in self._x_labels_major):
Expand Down Expand Up @@ -170,14 +167,12 @@ def line(self, serie, rescale=False):
else:
# plain vanilla rendering
sequences = [view_values]

#modified
if self.logarithmic:
if self.logarithmic:
for seq in sequences:
for ele in seq[::-1]:
if points[seq.index(ele)][1]==None or points[seq.index(ele)][1] <= 0:
del seq[seq.index(ele)]

y = points[seq.index(ele)][1]
if y is None or y <= 0:
del seq[seq.index(ele)]
for seq in sequences:
self.svg.line(
serie_node['plot'], seq, close=self._self_close,
Expand Down
6 changes: 3 additions & 3 deletions pygal/test/test_line_log_none_max_solved.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from pygal.test.utils import texts
from math import cos, sin

chart = Line(title='test', x_label_rotation=90, human_readable=True, logarithmic=True)
chart.add('test 1', [None, None, None, None, -38, 48, None, 4422, 34443, 345586, 40003452, 1235533, 2235533])
chart.add('test 2', [ 1, 7, 19, 30, 40, 20, 38, 283, 2937, 29374, 20399, 293874, 3947])
chart = Line(title='test', logarithmic=True)
chart.add('test 1', [None, -38, 48, 4422, 35586, 1003452, 225533])
chart.add('test 2', [1, 40, 20, 38, 2937, 20399, 3947])
q = chart.render_pyquery()
assert len(q(".dots")) == 20
2 changes: 1 addition & 1 deletion pygal/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def __init__(self, width, height, box):
def y(self, y):
"""Project y"""
if y is None or y <= 0 or self.log10_ymax - self.log10_ymin == 0:
return 0
return 0
return (self.height - self.height *
(log10(y) - self.log10_ymin) / (
self.log10_ymax - self.log10_ymin))
Expand Down

0 comments on commit 4b3fc71

Please sign in to comment.