Skip to content

Commit

Permalink
Implemented _cell_value helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Sep 7, 2016
1 parent 3297914 commit 4a92909
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions holoviews/plotting/mpl/tabular.py
Expand Up @@ -77,6 +77,20 @@ def _format_table(self):
return cell_widths


def _cell_value(self, element, row, col):
summarize = element.rows > self.max_rows
half_rows = self.max_rows//2
rows = min([self.max_rows, element.rows])
if summarize and row == half_rows:
cell_text = "..."
else:
if summarize and row > half_rows:
row = (element.rows - self.max_rows + row)
value = element.pprint_cell(row, col)
cell_text = self.pprint_value(value)
return cell_text


def pprint_value(self, value):
"""
Generate the pretty printed representation of a value for
Expand Down Expand Up @@ -115,7 +129,7 @@ def initialize_plot(self, ranges=None):
for col in range(element.cols):
if summarize and row > half_rows:
adjusted_row = (element.rows - self.max_rows + row)
cell_value = self.pprint_value(element.pprint_cell(row, col))
cell_value = self._cell_value(element, row, col)
cellfont = self.font_types.get(element.cell_type(adjusted_row,col), None)
width = self.cell_widths[col] / float(total_width)
font_kwargs = dict(fontproperties=cellfont) if cellfont else {}
Expand All @@ -135,7 +149,7 @@ def update_handles(self, key, axis, element, ranges, style):
table = self.handles['artist']

for coords, cell in table.get_celld().items():
value = self.pprint_value(element.pprint_cell(*coords))
value = self._cell_value(element, *coords)
cell.set_text_props(text=value)

# Resize fonts across table as necessary
Expand Down

0 comments on commit 4a92909

Please sign in to comment.