@@ -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' ])
122130class 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
153172class ChartManager (PluginManager ):
154173 def __init__ (self ):
0 commit comments