Collide force doesn't handle identical initial positions well

Aperta
#199 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@Fil ci sta già lavorando.

Dal 31/3/2023.

  • #214 di @Fil — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
20/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript

Direzione di ricerca

Read the collision force and initial-positioning code in d3-force to understand how coincident nodes are handled and how the default phyllotaxis arrangement works. Reproduce the reported behavior with nodes sharing the same x and y values, then compare the simulation with and without seeded jitter. Done means the collision force separates identical initial positions without requiring many extra ticks.

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

Descrizione

I'm working on a fixed force layout with collision and X and Y positioning. It's being rendered by React, and so I'm trying to optimize and speed up the force layout to reduce the expense of the simulation as my component may be resized, panned, and thus rerendered/resimulated quite often.

I found that initializing the node positions with the x and y properties greatly reduces the number of ticks needed to get the layout looking the way I want it. But it also causes some problems where the initial position is the same for several points, as in this map where I'm trying to cluster points around polygon centroids.

Screenshot 2021-07-15 at 12-28-29 Risk Demo

With another 40-50 ticks, it will settle down into something like this which is what I expect. (Possibly just due to floating point error?)

Screenshot 2021-07-15 at 12-36-36 Risk Demo

I can get the same effect with a shorter simulation by applying a deterministic (seeded) random jitter to the initial positions, but I thought it would be nice if D3 could handle this itself similar to the way the phyllotaxis arrangement around 0,0 does this for the default initial positions.

Lingua principale
JavaScript
Stelle
2k
Fork
395
Merge medio
5h 46m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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.

Altre issue di d3/d3-force

Tutte le issue di d3/d3-force

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.