Skip to content
Permalink
Browse files

Merge pull request #904 from ioam/linked_streams

Allow multiple streams attached to the same plot model
  • Loading branch information...
jlstevens committed Oct 5, 2016
2 parents 47b5582 + 5e79596 commit 8e14bbb55aa61589fca26571ceb0d3d0cc414bac
Showing with 26 additions and 6 deletions.
  1. +14 −2 holoviews/plotting/bokeh/callbacks.py
  2. +3 −1 holoviews/plotting/plot.py
  3. +9 −3 holoviews/util.py
@@ -133,6 +133,8 @@ class Callback(object):
# Timeout if a comm message is swallowed
timeout = 20000

_callbacks = {}

def __init__(self, plot, streams, source, **params):
self.plot = plot
self.streams = streams
@@ -162,7 +164,8 @@ def on_msg(self, msg):
if any(v is None for v in msg.values()):
return
for stream in self.streams:
stream.update(**msg)
stream.update(trigger=False, **msg)
Stream.trigger(self.streams)


def _process_msg(self, msg):
@@ -188,7 +191,16 @@ def set_customjs(self, handle):
for plot in plots:
handles.update(plot.handles)
# Set callback
handle.callback = CustomJS(args=handles, code=code)
if id(handle.callback) in self._callbacks:
cb = self._callbacks[id(handle.callback)]
if isinstance(cb, type(self)):
cb.streams += self.streams
else:
handle.callback.code += code
else:
js_callback = CustomJS(args=handles, code=code)
self._callbacks[id(js_callback)] = self
handle.callback = js_callback



@@ -486,7 +486,9 @@ def refresh(self, **kwargs):
"""
traverse_setter(self, '_force', True)
key = self.current_key if self.current_key else self.keys[0]
stream_params = stream_parameters(self.streams)
dim_streams = [stream for stream in self.streams
if any(c in self.dimensions for c in stream.contents)]
stream_params = stream_parameters(dim_streams)
key = tuple(None if d in stream_params else k
for d, k in zip(self.dimensions, key))
stream_key = util.wrap_tuple_streams(key, self.dimensions, self.streams)
@@ -1,10 +1,12 @@
import inspect

import param

from .core import DynamicMap, ViewableElement
from .core.operation import ElementOperation
from .core.util import Aliases
from .core import util

from .streams import Stream

class Dynamic(param.ParameterizedFunction):
"""
@@ -36,8 +38,12 @@ def __call__(self, map_obj, **params):
dmap = self._make_dynamic(map_obj, callback)
if isinstance(self.p.operation, ElementOperation):
streams = []
for s in self.p.streams:
stream = s()
for stream in self.p.streams:
if inspect.isclass(stream) and issubclass(stream, Stream):
stream = stream()
elif not isinstance(stream, Stream):
raise ValueError('Stream must only contain Stream '
'classes or instances')
stream.update(**{k: self.p.operation.p.get(k) for k, v in
stream.contents.items()})
streams.append(stream)

0 comments on commit 8e14bbb

Please sign in to comment.
You can’t perform that action at this time.