typedb / typedb-studio

TypeDB Studio (IDE)
https://typedb.com
Mozilla Public License 2.0
191 stars 43 forks source link

Maintain shape positioning in the graph #557

Open mathieuisabel opened 2 years ago

mathieuisabel commented 2 years ago

Please replace every line in curly brackets ( { like this } ) with appropriate answers, and remove this line.

Problem to Solve

When you run the same query over and over, you often to reposition the nodes in the graph to make sense of it at each query execution.

Current Workaround

None

Proposed Solution

Provide a way to maintain/persist node positioning for a particular query.

Additional Information

alexjpwalker commented 2 years ago

Right, I think this can be implemented with the following components:

  1. A toggle-button called "Remember layout" or similar. When clicked, add X+Y (gravity) forces to each vertex in the graph that gravitate the vertices towards their position at the time of clicking "Remember layout", and memorise which IID/Label is associated to each force. "Remember layout" is set on a per-File basis.
  2. On rerunning the query without modification, retain these X+Y forces so that each vertex gravitates back to its memorised position.
  3. On modifying the query file, if "Remember layout" is toggled ON, toggle it off and forget any memorised layout.

In the future, it would potentially be useful to save and load memorised layouts to disk. We should consider this when designing the feature.

mathieuisabel commented 2 years ago

There are probably considerations to be able to exchange that layout between people as you collaborate.

alexjpwalker commented 2 years ago

An interesting point. Provided all collaborators are connected to the same database server, the above strategy (where a layout is a map of IIDs/Labels to positions), with ability to save & load layouts to disk, would allow everyone to get the same layout when they perform that query.