Пример #1
0
    def _update_plot(self, plot, pane):
        from holoviews.core.util import cross_index, wrap_tuple_streams

        widgets = self.widget_box.objects
        if not widgets:
            return
        elif self.widget_type == 'scrubber':
            key = cross_index([v for v in self._values.values()], widgets[0].value)
        else:
            key = tuple(w.value for w in widgets)
            if plot.dynamic:
                widget_dims = [w.name for w in widgets]
                key = [key[widget_dims.index(kdim)] if kdim in widget_dims else None
                       for kdim in plot.dimensions]
                key = wrap_tuple_streams(tuple(key), plot.dimensions, plot.streams)

        if plot.backend == 'bokeh':
            if plot.comm or state._unblocked(plot.document):
                with unlocked():
                    plot.update(key)
                if plot.comm and 'embedded' not in plot.root.tags:
                    plot.push()
            else:
                if plot.document.session_context:
                    plot.document.add_next_tick_callback(partial(plot.update, key))
                else:
                    plot.update(key)
        else:
            plot.update(key)
            if hasattr(plot.renderer, 'get_plot_state'):
                pane.object = plot.renderer.get_plot_state(plot)
            else:
                # Compatibility with holoviews<1.13.0
                pane.object = plot.state
Пример #2
0
        def update_plot(change):
            from holoviews.core.util import cross_index
            from holoviews.plotting.bokeh.plot import BokehPlot

            widgets = self.widget_box.objects
            if self.widget_type == 'scrubber':
                key = cross_index([v for v in self._values.values()],
                                  widgets[0].value)
            else:
                key = tuple(w.value for w in widgets)

            plot = self._plots[root.ref['id']]
            if isinstance(plot, BokehPlot):
                if comm:
                    plot.update(key)
                    plot.push()
                else:

                    def update_plot():
                        plot.update(key)

                    plot.document.add_next_tick_callback(update_plot)
            else:
                plot.update(key)
                pane.object = plot.state
Пример #3
0
    def _update_plot(self, plot, pane, event):
        from holoviews.core.util import cross_index
        from holoviews.plotting.bokeh.plot import BokehPlot

        widgets = self.widget_box.objects
        if self.widget_type == 'scrubber':
            key = cross_index([v for v in self._values.values()], widgets[0].value)
        else:
            key = tuple(w.value for w in widgets)

        if isinstance(plot, BokehPlot):
            if plot.comm or plot.document is state.curdoc:
                plot.update(key)
                if plot.comm and 'embedded' not in plot.root.tags:
                    plot.push()
            else:
                plot.document.add_next_tick_callback(partial(plot.update, key))
        else:
            plot.update(key)
            pane.object = plot.state
Пример #4
0
    def _update_plot(self, plot, pane):
        from holoviews.core.util import cross_index

        widgets = self.widget_box.objects
        if not widgets:
            return
        elif self.widget_type == 'scrubber':
            key = cross_index([v for v in self._values.values()], widgets[0].value)
        else:
            key = tuple(w.value for w in widgets)

        if plot.backend == 'bokeh':
            if plot.comm or state._unblocked(plot.document):
                plot.update(key)
                if plot.comm and 'embedded' not in plot.root.tags:
                    plot.push()
            else:
                plot.document.add_next_tick_callback(partial(plot.update, key))
        else:
            plot.update(key)
            pane.object = plot.state
Пример #5
0
 def test_cross_index_large(self):
     values = [[chr(65 + i) for i in range(26)],
               list(range(500)), [chr(97 + i) for i in range(26)],
               [chr(48 + i) for i in range(10)]]
     self.assertEqual(cross_index(values, 50001), ('A', 192, 'i', '1'))
     self.assertEqual(cross_index(values, 500001), ('D', 423, 'c', '1'))
Пример #6
0
 def test_cross_index_depth_3(self):
     values = [self.values1, self.values2, self.values3]
     cross_product = list(product(*values))
     for i, p in enumerate(cross_product):
         self.assertEqual(cross_index(values, i), p)
Пример #7
0
 def test_cross_index_large(self):
     values = [[chr(65+i) for i in range(26)], list(range(500)),
               [chr(97+i) for i in range(26)], [chr(48+i) for i in range(10)]]
     self.assertEqual(cross_index(values, 50001), ('A', 192, 'i', '1'))
     self.assertEqual(cross_index(values, 500001), ('D', 423, 'c', '1'))
Пример #8
0
 def test_cross_index_depth_3(self):
     values = [self.values1, self.values2, self.values3]
     cross_product = list(product(*values))
     for i, p in enumerate(cross_product):
         self.assertEqual(cross_index(values, i), p)