Maps, Networks, and Timeline Visualizations
Summary
This chapter covers specialized visualization libraries for geographic, network, and temporal data. You will learn to create interactive maps using Leaflet.js with OpenMaps data, build network graphs and org charts with vis-network including force-directed layouts and node coloring. The chapter explores timeline visualizations with vis-timeline for events, durations, and sequences. You will also learn about specialized MicroSims for 3D visualization, circuit simulation, equation graphing, and advanced libraries like ReactFlow for complex interactive diagrams.
Concepts Covered
This chapter covers the following 28 concepts from the learning graph:
- Timeline Visualization
- Geographic Maps
- Leaflet.js
- Network Graphs
- vis-network Library
- Causal Loop Diagrams
- Equation Graphing
- Specialized MicroSims
- 3D Visualization
- Circuit Simulation
- Vis-network JS Library
- Graph Layout Algorithms
- History of GraphViz
- Forced Directed Layout
- Graph Node Coloring
- Org Chart Example
- Maps
- Leaflet JS Library
- OpenMaps Data
- Timelines
- Event Lists
- Durations
- Sequence Diagrams
- Heavyweight Libraries
- ReactFlow
- ER Diagram Example
- Vis-Timeline
- Venn Diagrams
Prerequisites
This chapter builds on concepts from:
- Chapter 2: Web Development Essentials
- Chapter 9: Bloom's Taxonomy and Learning Objectives
- Chapter 10: Charts, Diagrams, and Infographics
The Power of Relationship Visualization
Welcome to some of the most powerful MicroSims for analyzing concepts and their relationships. In this chapter, we move beyond simple charts to visualizations that reveal structure, connection, and flow.
Have you ever tried to manually lay out an organizational chart? Perhaps you've spent hours arranging boxes, drawing lines, only to have the structure change the next week. Then you start over. It's slow. It's painful. And it doesn't scale.
Fortunately, there are ways to automate the layout of complex structures. The origin story takes us back to Bell Labs in the 1980s, where a team created a product called GraphViz—a collection of layout algorithms that could automatically arrange nodes and edges into readable diagrams. From that pioneering work, many generations of products evolved. Today, many of these layout algorithms are available through JavaScript libraries like vis-network.
The Layout Algorithm Advantage
When you let algorithms handle positioning, you can focus on what matters: the relationships. Add a node, remove an edge, reorganize departments—the layout adapts automatically. That's the power we'll harness in this chapter.
Let's explore how these algorithms work and how we can bring order to complex network diagrams to build fun and insightful MicroSims.
Network Graphs: Visualizing Relationships
Network graphs (also called node-link diagrams) show entities as nodes and relationships as edges connecting them. They're ideal for:
- Organizational hierarchies
- Social networks
- Concept dependencies
- System architectures
- Knowledge graphs
Anatomy of a Network Graph
| Component | Description | Examples |
|---|---|---|
| Nodes | Entities or concepts | People, departments, topics |
| Edges | Relationships between nodes | Reports-to, connects-to, depends-on |
| Labels | Text identifying nodes/edges | Names, relationship types |
| Weights | Numeric values on edges | Strength, frequency, cost |
| Groups | Categories for nodes | Departments, types, levels |
When Network Graphs Excel
Use network graphs when:
- Relationships are as important as entities
- Structure is complex or hierarchical
- Users need to explore connections
- The graph changes over time
- Patterns emerge from connectivity
The History of GraphViz
The history of GraphViz begins at AT&T Bell Labs in the late 1980s. Researchers faced a common problem: how do you draw a graph with hundreds of nodes so that humans can understand it?
The Timeline
| Year | Development |
|---|---|
| 1988 | Initial GraphViz development at Bell Labs |
| 1991 | "dot" algorithm for hierarchical layouts |
| 1993 | "neato" for spring-model layouts |
| 1997 | Open-source release |
| 2000s | Web-based visualization libraries emerge |
| 2010s | JavaScript libraries (D3, vis.js) dominate |
| 2020s | Modern libraries (vis-network, ReactFlow) mature |
GraphViz Layout Algorithms
GraphViz introduced several graph layout algorithms that remain influential:
| Algorithm | Type | Best For |
|---|---|---|
| dot | Hierarchical | Org charts, flow diagrams, trees |
| neato | Spring model | Undirected graphs, clusters |
| fdp | Force-directed | Large graphs, organic layouts |
| twopi | Radial | Center-focused hierarchies |
| circo | Circular | Ring-structured graphs |
These algorithms solved the fundamental problem: given nodes and edges, compute (x, y) positions that make the structure readable.
Force-Directed Layout
The force-directed layout (also called spring-embedded layout) treats the graph as a physical system:
- Nodes repel each other like charged particles
- Edges attract connected nodes like springs
- The system reaches equilibrium when forces balance
How It Works
1 2 3 4 5 | |
Force-Directed Advantages
- Produces aesthetically pleasing layouts
- Reveals natural clusters
- No manual positioning required
- Adapts to graph changes
- Works for any graph structure
Force-Directed Limitations
- Computationally expensive for large graphs
- May produce different layouts each run
- Can get stuck in local minima
- Doesn't respect hierarchy without constraints
The vis-network Library
vis-network (part of the vis.js ecosystem) is a JavaScript library that brings GraphViz-style layout algorithms to the browser. It's the primary library we'll use for network graph MicroSims.
vis-network Features
- Multiple layout algorithms (hierarchical, force-directed)
- Interactive manipulation (drag, zoom, click)
- Node and edge styling
- Clustering and grouping
- Physics simulation
- Events and callbacks
- Performance optimization for large graphs
Basic vis-network Setup
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
Layout Options
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Graph Node Coloring
Graph node coloring uses color to encode additional information about nodes. Common patterns include:
| Coloring Strategy | Information Encoded | Example |
|---|---|---|
| By group | Category or type | Department colors |
| By level | Hierarchy depth | Darker = higher level |
| By metric | Numerical value | Red = high risk |
| By state | Current status | Green = active |
| By selection | User focus | Highlighted path |
Implementing Node Colors
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Org Chart Example
An org chart is a classic application of hierarchical network visualization. Let's build one:
Diagram: Interactive Org Chart MicroSim
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
Causal Loop Diagrams
Causal loop diagrams visualize feedback systems. They show how variables influence each other with positive (+) or negative (-) relationships.
Elements of Causal Loop Diagrams
| Element | Symbol | Meaning |
|---|---|---|
| Variable | Node | A quantity that changes |
| Positive link | → + | Same direction change |
| Negative link | → - | Opposite direction change |
| Reinforcing loop | R | Amplifying feedback |
| Balancing loop | B | Stabilizing feedback |
Example: Population Dynamics
1 2 | |
Building with vis-network
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
ER Diagram Example
Entity-Relationship (ER) diagrams model database schemas. They show entities (tables), attributes (columns), and relationships.
ER Diagram Elements
| Element | Representation |
|---|---|
| Entity | Rectangle |
| Attribute | Oval connected to entity |
| Relationship | Diamond between entities |
| Cardinality | 1, N, M on edges |
vis-network for ER Diagrams
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Geographic Maps with Leaflet.js
Geographic maps visualize location-based data. Leaflet.js (also called Leaflet JS Library) is a lightweight, open-source library for interactive maps.
Why Leaflet?
| Feature | Benefit |
|---|---|
| Lightweight | ~42KB gzipped |
| Mobile-friendly | Touch and gesture support |
| Extensible | Hundreds of plugins |
| Free tile sources | OpenStreetMap, others |
| Simple API | Easy to learn |
OpenMaps Data
OpenMaps data (primarily OpenStreetMap) provides free map tiles. Unlike Google Maps, there are no API keys or usage limits for basic tiles.
Basic Leaflet Setup
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Map Features for Education
| Feature | Use Case | Leaflet Method |
|---|---|---|
| Markers | Point locations | L.marker() |
| Polygons | Regions, boundaries | L.polygon() |
| Circles | Range, radius | L.circle() |
| Polylines | Routes, paths | L.polyline() |
| Popups | Information on click | .bindPopup() |
| Custom icons | Category markers | L.icon() |
Diagram: Interactive Map MicroSim
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
Timeline Visualization
Timeline visualization displays events across time. They're essential for:
- Historical education
- Project planning
- Process documentation
- Biographical content
- Event sequencing
Timeline Components
| Component | Description |
|---|---|
| Axis | Time scale (dates/years) |
| Items | Events with start (and optional end) |
| Groups | Categories or tracks |
| Range | Items with duration |
| Point | Single-moment events |
Vis-Timeline Library
Vis-Timeline (part of vis.js) creates interactive timelines with minimal code.
Basic Vis-Timeline Setup
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Event Lists and Durations
Event lists are collections of time-based items. Each event can be:
- A point (single moment):
{ start: '2024-01-15' } - A duration/range (time span):
{ start: '2024-01-15', end: '2024-02-20' }
1 2 3 4 5 6 7 8 9 10 | |
Grouped Timelines
Groups create parallel tracks:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Diagram: Historical Timeline MicroSim
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
Sequence Diagrams
Sequence diagrams show interactions between entities over time. They're ideal for:
- API call flows
- User interactions
- Protocol documentation
- System architecture
Mermaid Sequence Diagrams
1 2 3 4 5 6 7 8 9 10 11 12 | |
Sequence Diagram Elements
| Element | Mermaid Syntax | Meaning |
|---|---|---|
| Participant | participant A |
Entity in diagram |
| Sync message | A->>B: text |
Request with reply expected |
| Async message | A-)B: text |
Fire and forget |
| Return | B-->>A: text |
Response (dashed) |
| Note | Note right of A: text |
Annotation |
| Loop | loop text...end |
Repeated section |
| Alt | alt...else...end |
Conditional branches |
Venn Diagrams
Venn diagrams show set relationships—overlaps, unions, and intersections. They're useful for:
- Comparing concepts
- Showing shared characteristics
- Classification exercises
- Logical relationships
Building Venn Diagrams
While no major library specializes in Venn diagrams, they can be created with:
- SVG/CSS for simple static diagrams
- D3.js for interactive versions
- p5.js for educational MicroSims
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Specialized MicroSims
Beyond standard visualizations, specialized MicroSims serve specific educational domains.
3D Visualization
3D visualization uses WebGL libraries like Three.js for:
- Molecular structures
- Architectural models
- Geometric concepts
- Physics simulations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Circuit Simulation
Circuit simulation MicroSims teach electronics:
- Virtual breadboards
- Component libraries (resistors, capacitors, LEDs)
- Real-time voltage/current calculation
- Oscilloscope visualization
Libraries: CircuitJS, Falstad Circuit Simulator, custom p5.js
Equation Graphing
Equation graphing visualizes mathematical functions:
- Function plotting (y = f(x))
- Parametric curves
- 3D surfaces
- Interactive parameter exploration
Libraries: Desmos API, Plotly.js, JSXGraph, Function Plot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Heavyweight Libraries
Heavyweight libraries are full-featured frameworks for complex applications. They offer more power but require more setup.
ReactFlow
ReactFlow is a React-based library for building node-based interfaces:
- Drag-and-drop node creation
- Custom node types
- Connection handles
- Zoom and pan controls
- Undo/redo support
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
When to Use Heavyweight Libraries
| Choose Heavyweight When | Choose Lightweight When |
|---|---|
| Building production apps | Creating educational demos |
| Need React/Vue integration | Standalone HTML pages |
| Complex interaction patterns | Simple visualization |
| Professional-grade features | Quick prototypes |
| Long-term maintenance | One-off MicroSims |
Heavyweight vs. Lightweight Comparison
| Library | Type | Size | Learning Curve |
|---|---|---|---|
| vis-network | Lightweight | ~300KB | Low |
| D3.js | Flexible | ~250KB | High |
| ReactFlow | Heavyweight | ~150KB + React | Medium |
| Cytoscape.js | Heavyweight | ~500KB | Medium |
| GoJS | Commercial | ~1MB | Medium |
Complete Network MicroSim Example
Here's a complete vis-network MicroSim with interactive features:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
Key Takeaways
You've learned to create powerful visualizations for relationships, geography, and time:
-
Network graphs show entities and relationships as nodes and edges.
-
GraphViz history established foundational layout algorithms at Bell Labs in the 1980s.
-
Graph layout algorithms automatically position nodes for readability.
-
Force-directed layout simulates physics to find balanced arrangements.
-
vis-network brings professional graph visualization to JavaScript.
-
Graph node coloring encodes categories, status, or values visually.
-
Org charts use hierarchical layout for reporting structures.
-
Causal loop diagrams visualize feedback systems with +/- relationships.
-
ER diagrams model database schemas with entities and relationships.
-
Leaflet.js creates interactive maps using OpenMaps data.
-
Timeline visualization displays events and durations across time.
-
Vis-Timeline creates interactive timelines with groups and ranges.
-
Sequence diagrams show interactions between entities over time.
-
Venn diagrams visualize set relationships and overlaps.
-
Specialized MicroSims serve domains like 3D visualization, circuit simulation, and equation graphing.
-
Heavyweight libraries like ReactFlow offer production-grade features.
-
Choose the right library based on complexity, integration needs, and learning curve.
Challenge: Build a Concept Map
Create a vis-network MicroSim that visualizes concepts from a subject you teach. Include at least 10 nodes with labeled relationships. Use color to indicate concept categories and implement both force-directed and hierarchical layouts.
Next Steps
You now command powerful visualization tools for relationships, locations, and time. You can create org charts that reorganize themselves, maps that reveal geographic patterns, and timelines that make history interactive. In the next chapter, we'll explore physics and animation, adding realistic motion and behavior to your MicroSims.
Remember: the magic of layout algorithms is that they free you from manual positioning. Focus on the relationships, and let vis-network bring order to complexity.
References
- vis-network Documentation - Official vis-network docs
- Leaflet.js Documentation - Leaflet API reference
- vis-timeline Documentation - Timeline component docs
- GraphViz Documentation - Original GraphViz project
- OpenStreetMap - Free map data source
- ReactFlow Documentation - React-based node graphs