Graph Legends
Copy this iframe to your website:
1 | |
Description
This tutorial demonstrates how to create fixed-position legends for vis-network.js graph visualizations. Legends help users understand what different node shapes and colors represent in a network diagram.
Legend Versions
How to Use
- Observe the legend in the top-left corner of the visualization
- Note how each node type (Internet, Switch, Server, Computer, Smartphone) has a distinct shape and color
- The legend nodes are fixed in position and don't respond to physics simulation
Implementation Process
Step 1: Define Legend Position
1 2 3 4 | |
Step 2: Create Fixed Legend Nodes
Each legend node must have these attributes:
id(integer) - Unique identifierlabel(string) - Display textgroup(string) - Category for stylingvalue(integer) - Size valuefixed: true- Prevents movementphysics: false- Ignores physics simulation
1 2 3 4 5 6 7 8 9 10 | |
Step 3: Define Groups
1 2 3 4 5 6 7 | |
Lesson Plan
Learning Objectives
After completing this lesson, students will be able to:
- Create fixed-position legend nodes in vis-network.js
- Configure node groups with distinct shapes and colors
- Position legends relative to the canvas boundaries
- Understand the difference between fixed and physics-enabled nodes
Target Audience
- Web developers learning data visualization
- Prerequisites: JavaScript, HTML, basic vis-network.js knowledge
Activities
- Exploration Activity: Modify the legend to add a new node type
- Guided Investigation: Change the legend position to a different corner
- Extension Activity: Create a collapsible legend panel
Assessment
- What properties make a legend node stay fixed?
- Why set
physics: falseon legend nodes? - How do you position a legend relative to canvas edges?
References
- vis-network.js Groups - Official groups documentation
- vis-network.js Node Options - Node configuration options
- Fixed Nodes Example - Official legend example