plotly / plotly/plotly.js

Immutable mode

Aperta
#2,389 10 commenti 17 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature P3
Lingua principale
JavaScript
Stelle
18.3k
Fork
2k
Merge medio
2g 12h
PR unite (30g)
28

Descrizione

Along with Plotly.react, it would be nice if we would never mutate gd.data and gd.layout, just make new changed objects and alert the user to the change. We can't make this the default behavior in v1 since some users depend on gd.data and gd.layout keeping the identity of the objects they initially passed in - though there are some cases already where they are not. But that rule holds well enough that some folks depend on it, so immutability would have to be a config argument.

In general all of the plot modification methods except Plotly.react (Plotly.restyle, relayout, update, extendTraces etc..) modify gd.data and gd.layout in place to make the requested updates. Most (but not all) then emit an event you can use to see that the plot state has changed. But also there are modifications that happen automatically during drawing the plot, principally (if not entirely) pushing auto values (axis ranges, colorscale ranges) back to gd.data and gd.layout so that future minor updates don't need to recalculate these. This too is something we might be able to avoid doing, but probably not until v2.

So there are two things we should do:

  • Make all updates to gd.data and gd.layout immutably, conditional on a config argument.
  • Streamline the way we alert the user that the state has changed, so that they can feed this new state back into their app state. It seems like once we have immutable changes, it might be possible without any changes to the events from plotly.js... the react wrapper would have to bind to all the events that might carry state changes initiated from the UI, and also check after every update initiated by the wrapper itself, whether gd.data === prevData and gd.layout === prevLayout... but seems like it would be much easier for the react wrapper if there were a single "new state" event that collects all of these.

See https://github.com/plotly/react-plotly.js/issues/43

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 tracciando Plotly.react, Plotly.restyle, relayout, update ed extendTraces, quindi esamina l’issue #43 collegata di react-plotly.js. Determina in che modo gli aggiornamenti e il disegno modificano attualmente gd.data e gd.layout, inclusi i valori automatici e gli eventi di modifica dello stato. Il lavoro è completato quando gli aggiornamenti immutabili sono condizionati da un argomento config e le modifiche dello stato hanno un percorso di notifica ottimizzato.

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

Valutazione

Stack tecnologico
javascript
Ambito
data-visualization
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
20/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.