typedb / typedb-studio

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

Graph Visualiser: Always show vertex and edge labels, within reason #562

Closed alexjpwalker closed 2 years ago

alexjpwalker commented 2 years ago

What is the goal of this PR?

We've removed the limitation of Graph Visualiser where it would not render vertex and edge labels if the graph size was above a certain threshold.

What are the changes implemented in this PR?

Drawing text in Compose is much more expensive than drawing polygons. So we need to be more aggressive in choosing which texts to actually draw. Clearly, any text that we know to be fully outside the viewport should not be drawn.

We aim to ensure the initial "explosion" is as smooth as possible, and the resulting stable visualisation as rich as possible. The variables to consider are: total vertices/edges in graph; total vertices/edges in viewport; viewport scale; physics alpha.

Vertex rendering

Edge rendering

For edges, we have two draw modes: simple and detailed. A detailed edge has a label, and also, detailed edges can be curved. Because DrawScope.drawPoints is so cheap, we can draw all edges as simple by default, and detailed when they meet certain criteria: