Пример #1
0
    def __init__(self, graph_url='https://plot.ly/~playground/7', **kwargs):
        """Initialize a plotly graph widget

        Args:
            graph_url: The url of a Plotly graph

        Example:
            ```
            GraphWidget('https://plot.ly/~chris/3375')
            ```
        """
        super(GraphWidget, self).__init__(**kwargs)

        # TODO: Validate graph_url
        self._graph_url = graph_url
        self._listener_set = set()
        self._event_handlers = {
            'click': widgets.CallbackDispatcher(),
            'hover': widgets.CallbackDispatcher(),
            'zoom': widgets.CallbackDispatcher()
        }

        self._graphId = ''
        self.on_msg(self._handle_msg)

        # messages to the iframe client need to wait for the
        # iframe to communicate that it is ready
        # unfortunately, this two-way blocking communication
        # isn't possible
        # (https://github.com/ipython/ipython/wiki/IPEP-21:-Widget-Messages#caveats)
        # so we'll just cue up messages until they're ready to be sent
        self._clientMessages = deque()
Пример #2
0
 def __init__(self, data={}, schema=None, **kwargs):
     super(Widget, self).__init__(**kwargs)
     # Serialize and deserialize, make sure it's uniform.
     data = json.loads(json.dumps(data))
     if schema == None:
         schema = self.constructSchema(data)
     self.dataset = json.dumps({"data": data, "schema": schema})
     self.validate = widgets.CallbackDispatcher()
 def __init__(self, *pargs, **kwargs):
     widgets.DOMWidget.__init__(self, *pargs, **kwargs)
     self._handlers = widgets.CallbackDispatcher()
     self.on_msg(self._handle_my_msg)