observablehq / plot

A concise API for exploratory data visualization implementing a layered grammar of graphics
https://observablehq.com/plot/
ISC License
4.27k stars 174 forks source link

Force-directed graph #1708

Open mbostock opened 1 year ago

mbostock commented 1 year ago

Proof of concept using render transforms:

https://github.com/observablehq/plot/assets/230541/4799d063-20e6-4f2c-b91a-3ccb110f754f

https://observablehq.com/d/200ed525020b8df1

Still to figure out:

Fil commented 1 year ago

Nice! It would be great also to allow using other marks than dot & link? e.g. if you want images, or labels, to follow the dots, and links to be directed (and bent) arrows? The simulation and drag would be unchanged, but the display would be different.

RLesser commented 1 year ago

For a long while I've wanted a declarative way to generate d3 force graphs, so I'm really excited to see this get proposed / prototyped.

My desires for declarative d3 force graphs fall into 3 categories:

  1. Abilities that are in line with the current plot model, just applied to force graphs
    • the representation of the nodes (dots, images, arbitrary svg/html, etc.)
    • the representation of the edges (arrow/line, color, arc, etc.)
    • every aspect of the simulation (what forces are included, whether it has alpha decay, etc.)
  2. Abilities that fit the north-star design goals of Plot but are not yet implemented
    • Hovering nodes to see more info / trigger functions
    • dragging nodes around (either with other forces on or off)
    • panning and zooming on the force graph
  3. Abilities that probably have no place in Plot as currently designed
    • adding/removing nodes/edges from the graph itself, while the rest of the nodes/edges remain in position and react to the change in forces.

I'm curious how you see d3 force graphs in plot evolving, and where in this ability progression we might see a cutoff.

Relatedly, I wonder if force graphs (which don't fit the standards regarding x and y that all other marks do) would be treated as a different base level primitive, or whether you could have a marks array with a force graph mark and a bar mark coexisting.