Hi @mbostock. If I wanted to run this function outside of the Observable environment, what implication would `invalidation` have. As I understand it, this is an object that only exists in Observable.
Thanks. Beautiful graph, btw.
invalidation is optional; if you pass a promise, the function registers "simulation.stop" on this promise, so it can stop doing computations when it receives that message.
@dianaow sorry for the belated reply: we need these objects to hold the changing values of x, y, vx, vy during the simulation (as well as fx, fy if the user holds a node manually with the pointer).
Thanks for providing the notebook!
I'm trying to use your code outside of observablehq in a "traditional html-javascript constellation". I'm importing D3 via a CDN. As promised, your function ForceGraph() returns a <svg> element. However, I'm failing to append it to the DOM. By listening to the event 'DOMContentLoaded' I make sure, that D3 can access my target element. Can you please give me hint, how to append the <svg> to the DOM?
Thanks in advance
Alexander
Same issue on my side. I tried to append the created svg into my html by using:
d3.select('body').append('chart');
But it looks it's still the wrong way to go. No graph appear in the web page but at least no error either.
Any hint how to do it?