Skip to content

Commit 04d63c0

Browse files
committed
improve test coverage
1 parent 49e22fc commit 04d63c0

File tree

6 files changed

+50
-29
lines changed

6 files changed

+50
-29
lines changed

.moban.d/travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% extends "travis.yml.jj2" %}
22
{%block custom_python_versions%}
33
python:
4+
- pypy
45
- 3.6
56
- 3.5
67
- 3.4

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: python
33
notifications:
44
email: false
55
python:
6+
- pypy
67
- 3.6
78
- 3.5
89
- 3.4

docs/source/_static/single_xy_cosinus.svg

Lines changed: 2 additions & 2 deletions
Loading

pyexcel_pygal/chart.py

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ def render_sheet(self, sheet, title=DEFAULT_TITLE,
9191
height_in_column=0, start_in_column=1,
9292
stop_in_column=2,
9393
**keywords):
94-
histograms = zip(sheet.column[height_in_column],
95-
sheet.column[start_in_column],
96-
sheet.column[stop_in_column])
9794
cls = getattr(pygal, self._chart_class)
9895
instance = cls(title=title, **keywords)
99-
instance.add(sheet.name, histograms)
96+
self._render_a_sheet(instance, sheet,
97+
height_in_column=height_in_column,
98+
start_in_column=start_in_column,
99+
stop_in_column=stop_in_column)
100100
chart_content = instance.render()
101101
return chart_content
102102

@@ -108,15 +108,23 @@ def render_book(self, book, title=DEFAULT_TITLE,
108108
cls = getattr(pygal, self._chart_class)
109109
instance = cls(title=title, **keywords)
110110
for sheet in to_book(book):
111-
histograms = zip(sheet.column[height_in_column],
112-
sheet.column[start_in_column],
113-
sheet.column[stop_in_column])
114-
if PY2 is False:
115-
histograms = list(histograms)
116-
instance.add(sheet.name, histograms)
111+
self._render_a_sheet(instance, sheet,
112+
height_in_column=height_in_column,
113+
start_in_column=start_in_column,
114+
stop_in_column=stop_in_column)
117115
chart_content = instance.render()
118116
return chart_content
119117

118+
def _render_a_sheet(self, instance, sheet,
119+
height_in_column=0, start_in_column=1,
120+
stop_in_column=2):
121+
histograms = zip(sheet.column[height_in_column],
122+
sheet.column[start_in_column],
123+
sheet.column[stop_in_column])
124+
if PY2 is False:
125+
histograms = list(histograms)
126+
instance.add(sheet.name, histograms)
127+
120128

121129
@PluginInfo('chart', tags=['xy'])
122130
class XY(Chart):
@@ -127,6 +135,9 @@ def render_sheet(self, sheet, title=DEFAULT_TITLE,
127135
**keywords):
128136
cls = getattr(pygal, self._chart_class)
129137
instance = cls(title=title, **keywords)
138+
self._render_a_sheet(instance, sheet,
139+
x_in_column=x_in_column,
140+
y_in_column=y_in_column)
130141
points = zip(sheet.column[x_in_column],
131142
sheet.column[y_in_column])
132143
instance.add(sheet.name, points)
@@ -141,14 +152,22 @@ def render_book(self, book, title=DEFAULT_TITLE,
141152
cls = getattr(pygal, self._chart_class)
142153
instance = cls(title=title, **keywords)
143154
for sheet in to_book(book):
144-
points = zip(sheet.column[x_in_column],
145-
sheet.column[y_in_column])
146-
if not PY2:
147-
points = list(points)
148-
instance.add(sheet.name, points)
155+
self._render_a_sheet(instance, sheet,
156+
x_in_column=x_in_column,
157+
y_in_column=y_in_column)
149158
chart_content = instance.render()
150159
return chart_content
151160

161+
def _render_a_sheet(self, instance, sheet,
162+
x_in_column=0,
163+
y_in_column=1):
164+
165+
points = zip(sheet.column[x_in_column],
166+
sheet.column[y_in_column])
167+
if not PY2:
168+
points = list(points)
169+
instance.add(sheet.name, points)
170+
152171

153172
class ChartManager(PluginManager):
154173
def __init__(self):

0 commit comments

Comments
 (0)