diff --git a/pygal/graph/line.py b/pygal/graph/line.py index 3544d20..ff408e1 100644 --- a/pygal/graph/line.py +++ b/pygal/graph/line.py @@ -99,12 +99,9 @@ class Line(Graph): 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): @@ -170,14 +167,12 @@ class Line(Graph): 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, diff --git a/pygal/test/test_line_log_none_max_solved.py b/pygal/test/test_line_log_none_max_solved.py index ce0f2ec..1f7f9e2 100644 --- a/pygal/test/test_line_log_none_max_solved.py +++ b/pygal/test/test_line_log_none_max_solved.py @@ -8,8 +8,8 @@ from pygal import Line 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 diff --git a/pygal/view.py b/pygal/view.py index 0faa108..9360a58 100644 --- a/pygal/view.py +++ b/pygal/view.py @@ -343,7 +343,7 @@ class LogView(View): 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))