Browse Source

Merge pull request #343 from ShuaiQin/LogNoneValue

For #309 Log none value Solved
pull/373/merge
Mounier Florian 7 years ago committed by GitHub
parent
commit
840090534e
  1. 10
      pygal/graph/line.py
  2. 13
      pygal/test/test_line_log_none_max_solved.py

10
pygal/graph/line.py

@ -99,6 +99,9 @@ class Line(Graph):
for i, (x, y) in enumerate(view_values): for i, (x, y) in enumerate(view_values):
if None in (x, y): if None in (x, y):
continue continue
if self.logarithmic:
if points[i][1] is None or points[i][1] <= 0:
continue
if (serie.show_only_major_dots and if (serie.show_only_major_dots and
self.x_labels and i < len(self.x_labels) and self.x_labels and i < len(self.x_labels) and
self.x_labels[i] not in self._x_labels_major): self.x_labels[i] not in self._x_labels_major):
@ -164,7 +167,12 @@ class Line(Graph):
else: else:
# plain vanilla rendering # plain vanilla rendering
sequences = [view_values] sequences = [view_values]
if self.logarithmic:
for seq in sequences:
for ele in seq[::-1]:
y = points[seq.index(ele)][1]
if y is None or y <= 0:
del seq[seq.index(ele)]
for seq in sequences: for seq in sequences:
self.svg.line( self.svg.line(
serie_node['plot'], seq, close=self._self_close, serie_node['plot'], seq, close=self._self_close,

13
pygal/test/test_line_log_none_max_solved.py

@ -0,0 +1,13 @@
# This file is test file for NoneMaxSolved
# I have modified the line.py and passed other test
# This test is for us to test whether the none value
# in the Log graph will be max or not (issue #309)
from __future__ import division
from pygal import Line
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")) == 12
Loading…
Cancel
Save