d3 / d3-force

Force-directed graph layout using velocity Verlet integration.
https://d3js.org/d3-force
ISC License
1.82k stars 377 forks source link

Cant pass extra data in nodes in simulation.nodes function #211

Closed elVengador closed 2 years ago

elVengador commented 2 years ago

I want to pass extra data like nodeId to use later For example find a node under mouse cursor, then get nodeId and make some operations

Im building nodes inthis way:

const nodes: (SimulationNodeDatum)[] = notes.map(c => Object.create(c))

all extra data from notes is removed if I force like this:

const nodes: (SimulationNodeDatum)[] = notes.map(c => Object.create({ ...c, tmp: true }))

I have an error: image

Fil commented 2 years ago

It seems to be working here https://observablehq.com/@recifs/simulation-nodes-with-added-data--support