Learning Graph Legends
A legend is a key that shows you what different shapes, icons, images and colors imply in your learning graphs. We will demo two ways to place a legend on your learning graph and each method has tradeoffs.
Node Legend - which uses nodes in the upper left area to show the legend. This legend tends to move around based on the scale of the graph layout.
HTML Table Legend - which uses a HTML table in a CSS flexbox to display the legend. The HTML table is usually placed in a border region such as a left-sidebar. This allows you to collapse the sidebar with a toggle button (hamburger icon).
Node Legend
The node legend has the advantage that it can use exactly the same colors, shapes, icons and images as the nodes in the actual graph.
Here is a good example of how this might look:
Unfortunately, this legend can easily overlap with the actual graph network.
Here is a bad example where the actual nodes overlap the legend.
Sample of how node legends are use is at node-legend.js which was originally taken from the vis.js node legend example.
HTML Table Legend
HTML tables usually are located in a fixed position of the edge of a graph viewer. In the example above, we use a left-sidebar. They have the benefit of having a regular structure that is easy to align. They can also be configured to appear and disappear if the screen region is needed for viewing the full graph.
Felxbox Layout
The flexbox layout strategy allows us to just put in an HTML table with an max value. All the other region dimensions are calculated automatically with CSS.
Explanation:
display: flex
on thebody
element allows#sidebar
and#main
to sit side by side.#sidebar
automatically resizes based on its content, constrained bymax-width
.#main
withflex: 1
takes up the remaining available space.
This approach avoids conflicts and should handle dynamic sizing for the sidebar smoothly. Here’s an and example of the CSS using flexbox for layout control:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
Toggle Sidebar
Node Legends
https://jsfiddle.net/adgd87/szt7h6kv/19/