plotly / plotly/plotly.py

FigureWidget doesn't allow draggable polygon

Aperta
#4,374 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug P3
Lingua principale
Python
Stelle
18.8k
Fork
2.8k
Merge medio
16h 26m
PR unite (30g)
21

Descrizione

Using the following minimal code I wasn't able to draw a closed path and then drag and drop the polygon. Check the full error code.

from plotly.graph_objs._figurewidget import FigureWidget

FigureWidget(
    layout={
        'modebar': {
            "add": [
                "drawclosedpath",
                "eraseshape",
            ]
        },
    }
)
Full error code
ValueError                                Traceback (most recent call last)
File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:773, in Widget._handle_msg(self, msg)
    771         if 'buffer_paths' in data:
    772             _put_buffers(state, data['buffer_paths'], msg['buffers'])
--> 773         self.set_state(state)
    775 # Handle a state request.
    776 elif method == 'request_state':

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:650, in Widget.set_state(self, sync_data)
    645         self._send(msg, buffers=echo_buffers)
    647 # The order of these context managers is important. Properties must
    648 # be locked when the hold_trait_notification context manager is
    649 # released and notifications are fired.
--> 650 with self._lock_property(**sync_data), self.hold_trait_notifications():
    651     for name in sync_data:
    652         if name in self.keys:

File ~/micromamba/envs/streetsurface/lib/python3.10/contextlib.py:142, in _GeneratorContextManager.__exit__(self, typ, value, traceback)
    140 if typ is None:
    141     try:
--> 142         next(self.gen)
    143     except StopIteration:
    144         return False

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/traitlets/traitlets.py:1502, in HasTraits.hold_trait_notifications(self)
   1500 for changes in cache.values():
   1501     for change in changes:
-> 1502         self.notify_change(change)

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:701, in Widget.notify_change(self, change)
    698     if name in self.keys and self._should_send_property(name, getattr(self, name)):
    699         # Send new state to front-end
    700         self.send_state(key=name)
--> 701 super().notify_change(change)

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/traitlets/traitlets.py:1517, in HasTraits.notify_change(self, change)
   1515 def notify_change(self, change):
   1516     """Notify observers of a change event"""
-> 1517     return self._notify_observers(change)

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/traitlets/traitlets.py:1564, in HasTraits._notify_observers(self, event)
   1561 elif isinstance(c, EventHandler) and c.name is not None:
   1562     c = getattr(self, c.name)
-> 1564 c(event)

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/plotly/basewidget.py:644, in BaseFigureWidget._handler_js2py_relayout(self, change)
    640     relayout_data.pop("lastInputTime")
    642 # Perform relayout
    643 # ----------------
--> 644 self.plotly_relayout(relayout_data=relayout_data, source_view_id=source_view_id)
    646 self._js2py_relayout = None

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/plotly/basedatatypes.py:2612, in BaseFigure.plotly_relayout(self, relayout_data, **kwargs)
   2608     msg_kwargs = {}
   2610 # Perform relayout operation on layout dict
   2611 # -----------------------------------------
-> 2612 relayout_changes = self._perform_plotly_relayout(relayout_data)
   2613 if relayout_changes:
   2614     # The relayout operation resulted in a change to some layout
   2615     # properties, so we dispatch change callbacks and send the
   2616     # relayout message to the frontend (if any)
   2617     self._send_relayout_msg(relayout_changes, **msg_kwargs)

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/plotly/basedatatypes.py:2648, in BaseFigure._perform_plotly_relayout(self, relayout_data)
   2644         for key_path_str, v in relayout_data.items():
   2646             if not BaseFigure._is_key_path_compatible(key_path_str, self.layout):
-> 2648                 raise ValueError(
   2649                     """
   2650 Invalid property path '{key_path_str}' for layout
   2651 """.format(
   2652                         key_path_str=key_path_str
   2653                     )
   2654                 )
   2656             # Apply set operation on the layout dict
   2657             val_changed = BaseFigure._set_in(self._layout, key_path_str, v)

ValueError: 
Invalid property path 'shapes[0].path' for layout

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo l'esempio minimo di FigureWidget e segui BaseFigureWidget._handler_js2py_relayout fino a BaseFigure._perform_plotly_relayout, dove viene sollevato l'errore a causa del percorso della proprietà non valido shapes[0].path. Controlla come drawclosedpath e il trascinamento aggiornano gli shapes del layout, quindi verifica che il disegno e il trascinamento di un poligono chiuso non sollevino più questo errore.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
jupyter-notebook, python
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.