plotly / plotly/plotly.py

Error on shape editing with `dcc.Graph`: Invalid property specified for object of type plotly.graph_objs.layout.shape.label: 'texttemplate'

Aperta
#4,462 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

I use dash components in my Flask app to render shapes on a dcc.Graph figure input. Oftentimes, this involves appending a list of shapes to the graph using the formula below:

for center in center_list:
            center = region.centroid
            annotation = cluster_frame[cluster_frame['cell_id'] == mask_id]['cluster']
            if len(annotation) > 0:
                annotation = str(annotation.tolist()[0])
                # boundary[int(center[0]), int(center[1])] = mask_id
                shapes.append(
                    {'editable': False, 'line': {'color': 'white'}, 'type': 'circle',
                     'x0': (int(center[1]) - circle_size), 'x1': (int(center[1]) + circle_size),
                     'xref': 'x', 'y0': (int(center[0]) - circle_size), 'y1': (int(center[0]) + circle_size),
                     'yref': 'y',
                     'fillcolor': cluster_assignments[data_selection][annotation]})
        self.figure['layout']['shapes'] = shapes

In the example above, a series of circles are generated around centroids for objects in the graph.
This scheme generally works well, but occasionally there will be in the following error when calling go.Figure(self.figure):

Invalid property specified for object of type plotly.graph_objs.layout.shape.label: 'texttemplate'

When I evaluate the shapes, sometimes they have a strange property added to them:

{'editable': False, 'line': {'color': 'white'}, 'type': 'circle', 'x0': 763, 'x1': 779, 'xref': 'x', 'y0': 284, 'y1': 300, 'yref': 'y', 'label': {'texttemplate': ''}}

It appears that plotly will randomly generate the label portion of the shape dictionary with a blank text template, which causes an error. It seems to happen indiscriminately and without a discernible pattern.

By comparison, most shapes appear to have a valid dictionary structure:

{'editable': True, 'line': {'color': 'white'}, 'type': 'circle', 'x0': 796, 'x1': 812, 'xref': 'x', 'y0': 293, 'y1': 309, 'yref': 'y'}

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 dalla chiamata go.Figure(self.figure) e analizza come i dizionari delle forme arrivano a plotly.graph_objs.layout.shape.label. Riproduci il problema con le cerchi forniti e confronta i casi con e senza label.texttemplate; il lavoro è completato quando l’errore intermittente invalid-property segnalato è spiegato e non si verifica più con l’input mostrato.

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

Valutazione

Stack tecnologico
flask, python
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.