Modern Angular 20+ component library for Cytoscape graph visualization
A production-ready Angular library providing sophisticated graph visualization capabilities using Cytoscape.js.
Check out the demo.
- π― Modern Angular 20 - Built with the latest Angular features: signals, standalone components, and proper RxJS patterns
- π Dynamic Forms - Sophisticated form system that automatically adapts based on graph layout type
- β‘ Signal-Based - Reactive state management using Angular signals for optimal performance
- π¨ Material Design - Beautiful UI components using Angular Material
- πͺ Type-Safe - Full TypeScript support with comprehensive type definitions
- π§ͺ Well-Tested - Extensive test coverage with Jasmine and Karma
- π’ Production-Ready - Professional code patterns suitable for enterprise applications
- Dynamic Form Generation - Forms that change based on configuration metadata (see
FluidFormComponent
) - Signal-Based Architecture - Modern reactive patterns with Angular signals
- Standalone Components - Latest Angular architecture without NgModules
- Type-Safe Configuration - Self-describing components with type-safe metadata
- Professional Testing - Comprehensive unit and integration tests
npm install cytoscape-angular cytoscape cytoscape-dagre
npm install @angular/material @angular/cdk
import { Component, signal } from '@angular/core';
import {
CytoscapeGraphComponent,
CytoscapeGraphToolbarComponent,
GridLayoutOptions
} from 'cytoscape-angular';
@Component({
selector: 'app-root',
standalone: true,
imports: [CytoscapeGraphComponent, CytoscapeGraphToolbarComponent],
template: `
<cyng-cytoscape-graph
[nodes]="nodes()"
[edges]="edges()"
[layoutOptions]="layoutOptions()"
/>
<cyng-cytoscape-graph-toolbar
[(layoutOptions)]="layoutOptions"
[nodes]="nodes()"
[edges]="edges()"
/>
`
})
export class AppComponent {
nodes = signal([
{ data: { id: 'a', label: 'Node A' } },
{ data: { id: 'b', label: 'Node B' } }
]);
edges = signal([
{ data: { id: 'ab', source: 'a', target: 'b' } }
]);
layoutOptions = signal(new GridLayoutOptions());
}
The main graph visualization component.
<cyng-cytoscape-graph
[nodes]="nodes()"
[edges]="edges()"
[style]="styles()"
[layoutOptions]="layout()"
[debug]="true"
(graphReady)="onReady($event)"
/>
Key Methods:
centerElements(selector: string)
- Center elements matching selectorzoomToElement(selector: string, level?: number)
- Zoom to specific elementgetCytoscapeInstance()
- Get underlying Cytoscape instance
Toolbar with layout and styling controls.
<cyng-cytoscape-graph-toolbar
[(layoutOptions)]="layoutOptions"
[(styles)]="styles"
[nodes]="nodes()"
[edges]="edges()"
[direction]="'row'"
(styleSelectorChange)="onSelectorChange($event)"
/>
Layout configuration with dynamic forms.
<cyng-cytoscape-layout-tool
[(layoutOptions)]="layoutOptions"
/>
Supported Layouts:
- Grid - Regular grid pattern
- Circle - Circular arrangement
- Concentric - Concentric circles
- Breadth-First - Hierarchical tree
- CoSE - Force-directed
- Dagre - Directed acyclic graph
- Random - Random positions
- Preset - Predefined positions
Metadata-based Dynamic Forms π―
A dynamic form generator that creates forms from metadata, driving the graph options for each graph type.
<cyng-fluid-form
[(model)]="layoutOptions"
[formInfo]="formInfo"
/>
Dynamic Form Fetures:
- Type-Safe - Infers field types from model
- Dynamic - Form changes based on configuration
- Reactive - Two-way binding with signals
- Validatable - Built-in validation support
- Conditional - Shows/hides fields based on model state
// β
Signals for state management
readonly nodes = signal<NodeDefinition[]>([]);
// β
Computed values
readonly nodeCount = computed(() => this.nodes().length);
// β
Signal-based inputs
readonly debug = input(false);
// β
Model signals for two-way binding
readonly layoutOptions = model<LayoutOptions>({...});
// β
ViewChild as signals
readonly graph = viewChild<CytoscapeGraphComponent>('graph');
// β
takeUntilDestroyed for automatic cleanup
effect(() => {
this.http.get(url)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(...);
});
@Component({
selector: 'cyng-graph',
standalone: true, // β
No NgModules
imports: [CommonModule, MatButtonModule],
...
})
Run the comprehensive test suite:
# Test library
npm run test:lib
# Test demo
npm run test:demo
# CI mode with coverage
npm run test:ci
Test Coverage Includes:
- Component rendering
- Signal reactivity
- Form generation
- Graph interactions
- Layout algorithms
- Style application
# Build library
npm run build
# Build production library
npm run build:prod
# Watch mode for development
npm run watch
Run the sophisticated demo showcasing all features:
npm start
Navigate to http://localhost:4200
Demo Features:
- Interactive TGF-Ξ² biological pathway
- Real-time layout switching
- Dynamic form updates
- Professional styling
- Comprehensive examples
This library includes:
- β Strict TypeScript configuration
- β ESLint with Angular rules
- β Comprehensive test coverage
- β Production build optimization
- β Tree-shakeable exports
- β Proper error handling
- β Accessibility support
- β Documentation
MIT License - see LICENSE file for details
Michael Bushe - Mindful Software
- Cytoscape.js - Powerful graph visualization library
- Angular - Amazing framework
- Angular Material - Beautiful components
Built with β€οΈ using Angular 20 by Michael Bushe of Mindful Software