コード例 #1
0
ファイル: renderer.py プロジェクト: joelostblom/holoviews
    def _validate(self, obj, fmt, **kwargs):
        """
        Helper method to be used in the __call__ method to get a
        suitable plot or widget object and the appropriate format.
        """
        if isinstance(obj, Viewable):
            return obj, 'html'

        fig_formats = self.mode_formats['fig']
        holomap_formats = self.mode_formats['holomap']

        holomaps = obj.traverse(lambda x: x, [HoloMap])
        dynamic = any(isinstance(m, DynamicMap) for m in holomaps)

        if fmt in ['auto', None]:
            if any(len(o) > 1 or (isinstance(o, DynamicMap) and unbound_dimensions(o.streams, o.kdims))
                   for o in holomaps):
                fmt = holomap_formats[0] if self.holomap in ['auto', None] else self.holomap
            else:
                fmt = fig_formats[0] if self.fig == 'auto' else self.fig

        if fmt in self.widgets:
            plot = self.get_widget(obj, fmt)
            fmt = 'html'
        elif dynamic or (self._render_with_panel and fmt == 'html'):
            plot, fmt = HoloViewsPane(obj, center=True, backend=self.backend, renderer=self), fmt
        else:
            plot = self.get_plot(obj, renderer=self, **kwargs)

        all_formats = set(fig_formats + holomap_formats)
        if fmt not in all_formats:
            raise Exception("Format %r not supported by mode %r. Allowed formats: %r"
                            % (fmt, self.mode, fig_formats + holomap_formats))
        self.last_plot = plot
        return plot, fmt
コード例 #2
0
 def app(self_or_cls,
         plot,
         show=False,
         new_window=False,
         websocket_origin=None,
         port=0):
     """
     Creates a bokeh app from a HoloViews object or plot. By
     default simply attaches the plot to bokeh's curdoc and returns
     the Document, if show option is supplied creates an
     Application instance and displays it either in a browser
     window or inline if notebook extension has been loaded.  Using
     the new_window option the app may be displayed in a new
     browser tab once the notebook extension has been loaded.  A
     websocket origin is required when launching from an existing
     tornado server (such as the notebook) and it is not on the
     default port ('localhost:8888').
     """
     if isinstance(plot, HoloViewsPane):
         pane = plot
     else:
         pane = HoloViewsPane(plot,
                              backend=self_or_cls.backend,
                              renderer=self_or_cls,
                              **self_or_cls._widget_kwargs())
     if new_window:
         return pane._get_server(port, websocket_origin, show=show)
     else:
         kwargs = {
             'notebook_url': websocket_origin
         } if websocket_origin else {}
         return pane.app(port=port, **kwargs)
コード例 #3
0
ファイル: renderer.py プロジェクト: joelostblom/holoviews
 def server_doc(self_or_cls, obj, doc=None):
     """
     Get a bokeh Document with the plot attached. May supply
     an existing doc, otherwise bokeh.io.curdoc() is used to
     attach the plot to the global document instance.
     """
     if not isinstance(obj, HoloViewsPane):
         obj = HoloViewsPane(obj, renderer=self_or_cls, backend=self_or_cls.backend,
                             **self_or_cls._widget_kwargs())
     return obj.layout.server_doc(doc)
コード例 #4
0
ファイル: renderer.py プロジェクト: joelostblom/holoviews
    def get_widget(self_or_cls, plot, widget_type, **kwargs):
        if widget_type == 'scrubber':
            widget_location = self_or_cls.widget_location or 'bottom'
        else:
            widget_type = 'individual'
            widget_location = self_or_cls.widget_location or 'right'

        layout = HoloViewsPane(plot, widget_type=widget_type, center=True,
                               widget_location=widget_location, renderer=self_or_cls)
        interval = int((1./self_or_cls.fps) * 1000)
        for player in layout.layout.select(PlayerBase):
            player.interval = interval
        return layout