Skip to content

Commit

Permalink
Fixed updating of bokeh tables
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Sep 7, 2016
1 parent ce1ed4c commit e39baab
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions holoviews/plotting/bokeh/tabular.py
Expand Up @@ -2,9 +2,11 @@

import param

from .plot import BokehPlot
from ...core import Dataset
from ...element import ItemTable
from ..plot import GenericElementPlot

from .plot import BokehPlot
from .util import bokeh_version

class TablePlot(BokehPlot, GenericElementPlot):

Expand All @@ -15,6 +17,15 @@ class TablePlot(BokehPlot, GenericElementPlot):
style_opts = ['row_headers', 'selectable', 'editable',
'sortable', 'fit_columns', 'width', 'height']

_update_handles = ['source', 'glyph']

def __init__(self, element, plot=None, show_labels=['x', 'y'], **params):
super(TablePlot, self).__init__(element, **params)
self.handles = {} if plot is None else self.handles['plot']
element_ids = self.hmap.traverse(lambda x: id(x), [Dataset, ItemTable])
self.static = len(set(element_ids)) == 1 and len(self.keys) == len(self.hmap)


def get_data(self, element, ranges=None, empty=False):
dims = element.dimensions()
return ({d.name: [] if empty else element.dimension_values(d) for d in dims},
Expand Down Expand Up @@ -48,6 +59,31 @@ def initialize_plot(self, ranges=None, plot=None, plots=None, source=None):
return table


@property
def current_handles(self):
"""
Returns a list of the plot objects to update.
"""
handles = []
if self.static and not self.dynamic:
return handles

previous_id = self.handles.get('previous_id', None)
current_id = id(self.current_frame.data) if self.current_frame else None
for handle in self._update_handles:
if (handle == 'source' and self.dynamic and
current_id == previous_id):
continue
if handle in self.handles:
handles.append(self.handles[handle])

# Cache frame object id to skip updating if unchanged
if self.dynamic:
self.handles['previous_id'] = current_id

return handles


def update_frame(self, key, ranges=None, plot=None):
"""
Updates an existing plot with data corresponding
Expand Down

0 comments on commit e39baab

Please sign in to comment.