Editable Force Graph as viewof


I’ve been trying to adapt my editable force graph notebook into one where the rendering and editable data are combined, as this would make it more modifiable and compact. Based on what I’ve read of viewof it seems that having my graph be a viewof graph and the underlying data be the value associated with graph would serve this purpose well, as viewof is inherently mutable.

I’ve made a basic (and incomplete) attempt at this in this notebook, but it definitely is not working and I’m unsure of how exactly to make it even show the nodes update correctly, let alone edit it from within the block or from other blocks. Any advice on how to make something like this work?



You not only need to change the value of the element, you also have to dispatch an “input” event, so viewof updates the value.
You have a neat example here: https://observablehq.com/@darthmall/svg-input