Accepted
We needed an interactive graph visualization for:
- Real-time conversation flow inspection
- Node type and emotion visualization
- Current node highlighting during conversation
- Zoom, pan, and node inspection
- Educational value for understanding graph structure
Requirements:
- Interactive (drag nodes, zoom, pan)
- Real-time updates as conversation progresses
- Custom styling for node types and states
- Reasonable learning curve
- Good TypeScript support
We chose D3.js with a force-directed graph layout.
const simulation = d3.forceSimulation(nodes)
.force('link', d3.forceLink(links).id(d => d.id).distance(120))
.force('charge', d3.forceManyBody().strength(-400))
.force('center', d3.forceCenter(width / 2, height / 2));- Force-directed layout: Natural node positioning
- Draggable nodes: Users can rearrange the graph
- Zoom controls: Zoom in/out, reset view
- Color coding: Different colors for node types
- Real-time highlighting: Current node glows orange
- Visited tracking: Visited nodes turn green
- Edge labels: Show trigger types/intents
- Legend: Explains color coding
const nodeColors = {
bot: '#3b82f6', // Blue
'user-input': '#10b981', // Green
decision: '#f59e0b', // Amber
end: '#ef4444', // Red
visited: '#22c55e', // Green (bright)
current: '#f97316' // Orange (glowing)
};- ✅ Highly interactive and engaging
- ✅ Real-time updates as conversation progresses
- ✅ Educational value for understanding graph structure
- ✅ Professional appearance
- ✅ Full control over styling and behavior
- ❌ D3.js has a steep learning curve
- ❌ Bundle size increase (~80KB gzipped)
- ❌ More code than simpler visualization libraries
- ❌ Force simulation can be unpredictable initially
- Encapsulated D3 logic in single component
- Provided zoom controls and reset button
- Added legend for clarity
- Simulation stabilizes after initial render
- Rejected due to limited customization for force-directed layouts
- Considered but D3 has more examples and maturity
- Good alternative but D3 has better React ecosystem fit
- Not suitable for network/graph visualizations