Force Graph Library โ
A powerful, flexible TypeScript library for creating interactive force-directed graph visualizations with advanced features like grouping, clustering, and customizable styling.
๐ Features โ
- Interactive Force-Directed Graphs - Smooth, physics-based node positioning
- Advanced Grouping - Visual organization of related nodes with customizable borders and labels
- Dynamic Data Management - Add, update, and remove nodes/links in real-time
- TypeScript Support - Full type safety with comprehensive interfaces
- Performance Optimized - Dynamic cooldown calculation and efficient rendering
- Highly Customizable - Extensive styling options for nodes, links, and groups
- Event Handling - Rich interaction capabilities with click handlers and more
- Clustering Support - Built-in support for node clustering algorithms
- Directional Particles - Animated particles along links for flow visualization
๐ Requirements โ
- Node.js 14+ or modern browser environment
- TypeScript 4.0+ (recommended)
๐ ๏ธ Dependencies โ
force-graph- Core force-directed graph rendererd3- Data visualization libraryd3-force-clustering- Clustering algorithms
๐ฏ Quick Example โ
typescript
import { ForceGraph } from '@logixode/force-graph-lib'
const container = document.getElementById('graph-container')!
const data = {
nodes: [
{ id: '1', label: 'Node 1', color: '#ff6b6b' },
{ id: '2', label: 'Node 2', color: '#4ecdc4' },
{ id: '3', label: 'Node 3', color: '#45b7d1' },
],
links: [
{ source: '1', target: '2' },
{ source: '2', target: '3' },
],
}
const graph = new ForceGraph(container, data, {
width: 800,
height: 600,
nodeSize: 5,
showGroups: true,
})๐ Getting Started โ
Install dependencies
shnpm install force-graph d3 d3-force-clusteringImport the library
typescriptimport { ForceGraph } from '@logixode/force-graph-lib' import type { GraphData } from '@logixode/force-graph-lib'Create your first graph
- See Getting Started Guide for detailed instructions
- Check Basic Usage for simple examples
๐ค Contributing โ
Built on top of excellent open-source libraries:
- force-graph by @vasturiano
- D3.js force simulation engine
- d3-force-clustering for clustering