MCPcopy Index your code
hub / github.com/plotly/plotly.py / _Table

Class _Table

plotly/figure_factory/_table.py:167–280  ·  view source on GitHub ↗

Refer to TraceFactory.create_table() for docstring

Source from the content-addressed store, hash-verified

165
166
167class _Table(object):
168 """
169 Refer to TraceFactory.create_table() for docstring
170 """
171
172 def __init__(
173 self,
174 table_text,
175 colorscale,
176 font_colors,
177 index,
178 index_title,
179 annotation_offset,
180 **kwargs,
181 ):
182 if pd and isinstance(table_text, pd.DataFrame):
183 headers = table_text.columns.tolist()
184 table_text_index = table_text.index.tolist()
185 table_text = table_text.values.tolist()
186 table_text.insert(0, headers)
187 if index:
188 table_text_index.insert(0, index_title)
189 for i in range(len(table_text)):
190 table_text[i].insert(0, table_text_index[i])
191 self.table_text = table_text
192 self.colorscale = colorscale
193 self.font_colors = font_colors
194 self.index = index
195 self.annotation_offset = annotation_offset
196 self.x = range(len(table_text[0]))
197 self.y = range(len(table_text))
198
199 def get_table_matrix(self):
200 """
201 Create z matrix to make heatmap with striped table coloring
202
203 :rtype (list[list]) table_matrix: z matrix to make heatmap with striped
204 table coloring.
205 """
206 header = [0] * len(self.table_text[0])
207 odd_row = [0.5] * len(self.table_text[0])
208 even_row = [1] * len(self.table_text[0])
209 table_matrix = [None] * len(self.table_text)
210 table_matrix[0] = header
211 for i in range(1, len(self.table_text), 2):
212 table_matrix[i] = odd_row
213 for i in range(2, len(self.table_text), 2):
214 table_matrix[i] = even_row
215 if self.index:
216 for array in table_matrix:
217 array[0] = 0
218 return table_matrix
219
220 def get_table_font_color(self):
221 """
222 Fill font-color array.
223
224 Table text color can vary by row so this extends a single color or

Callers 1

create_tableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected