예제 #1
0
파일: viewable.py 프로젝트: jsignell/panel
 def _get_customjs(self, change, client_comm, plot_id):
     """
     Returns a CustomJS callback that can be attached to send the
     model state across the notebook comms.
     """
     data_template = "data = {{{change}: cb_obj['{change}']}};"
     fetch_data = data_template.format(change=change)
     self_callback = JS_CALLBACK.format(comm_id=client_comm.id,
                                        timeout=self._timeout,
                                        debounce=self._debounce,
                                        plot_id=plot_id)
     js_callback = CustomJS(code='\n'.join([fetch_data, self_callback]))
     return js_callback
예제 #2
0
파일: __init__.py 프로젝트: ioam/parambokeh
 def _get_customjs(self, change, p_name):
     """
     Returns a CustomJS callback that can be attached to send the
     widget state across the notebook comms.
     """
     data_template = "data = {{p_name: '{p_name}', value: cb_obj['{change}']}};"
     fetch_data = data_template.format(change=change, p_name=p_name)
     self_callback = JS_CALLBACK.format(comm_id=self.comm.id,
                                        timeout=self.timeout,
                                        debounce=self.debounce,
                                        plot_id=self.plot_id)
     js_callback = CustomJS(code='\n'.join([fetch_data,
                                            self_callback]))
     return js_callback
예제 #3
0
def get_comm_customjs(change, client_comm, plot_id, timeout=5000, debounce=50):
    """
    Returns a CustomJS callback that can be attached to send the
    model state across the notebook comms.
    """
    # Abort callback if value matches last received event
    abort = ABORT_JS.format(plot_id=plot_id, change=change)
    data_template = "data = {{{change}: cb_obj['{change}'], 'id': cb_obj.id}};"
    fetch_data = data_template.format(change=change)
    self_callback = JS_CALLBACK.format(comm_id=client_comm.id,
                                       timeout=timeout,
                                       debounce=debounce,
                                       plot_id=plot_id)
    return CustomJS(code='\n'.join([abort, fetch_data, self_callback]))