This documentation is based on development learnings and may be updated as the implementation evolves.
Repository Information
Repository: custom-diagrams-library While named generically as “library,” this repository is specifically focused on Atlas Tube diagrams and serves as the primary example of complex custom diagram implementation.Architecture Overview
Diagram Type Parameter
A key innovation in the Atlas Tube implementation is the introduction of adiagramType parameter, which allows one compiled ES module to include multiple diagram variations.
Data Flow Architecture
The data flow is consistent for bothinteractive and static diagrams, and across all Atlas Tube diagram types:
Detailed Data Flow
Detailed Data Flow
1. Initialize Phase
File:src/interactive/interface.ts : initialize()- Sets up basic framework
- Does minimal work but still required
2. Client Initialize Phase
File:src/interactive/interface.ts : clientInitialize()- Creates blank canvas
- Switches to appropriate diagram type
- Calls:
src/spliceAtlas/ParamsInterface.ts : defaultParams- Loads default parameters for the diagram
- Calls:
src/spliceAtlas/render.ts : update()- Resizes canvas to fit
- Renders elements with default parameters
- Calls:
src/spliceAtlas/getTransformations.ts: getTransformations()- Reformats original parameters into positioning data
- Calculates anchor points for diagram elements
- Returns to:
src/spliceAtlas/render.ts : update()- Transforms the calculated elements
- Draws text and leader lines
3. Render Phase
File:src/interactive/interface.ts : render()- Clears existing canvas
- Switches to appropriate diagram type
- Similar steps to
clientInitialize()but with actual sheet parameters - Renders final diagram with real calculation data
Component Architecture
Shared Components
Testing and Development
Local Testing Setup
Testing Configuration
It can take significant time to understand the testing setup requirements. The dual-process requirement and parameter passing are not immediately obvious from the documentation.
Alternative Approaches Discussion
Current Limitations
The current implementation raises questions about whether there might be more efficient approaches:Potential Alternative Technologies
Potential Alternative Technologies
Native SVG with Parameters
- SVG has native support for parametric variables
- Could potentially eliminate JavaScript entirely
- May become complex with arbitrary numbers of elements
- Current implementation uses low-level SVG.js and svgdom
- Alternative libraries like Snap.svg or Maker.js might provide better abstractions
- Could improve development speed and maintainability
- Engineers are already familiar with parametric drafting tools
- DXF is a vector format that can convert to/from SVG
- Might enable direct CAD-to-diagram workflows
Design Philosophy
Core Question: What are we actually doing?At its essence, we’re creating parametric technical drawings:
- Copying shared components into project-specific details
- Parameterizing placement of lines and labels
- Generating vector drawings for web display
Implementation Best Practices
Parameter Management
Error Handling
Performance Optimization
Future Considerations
Scalability
As more custom diagrams are developed, consider:- Shared Component Library: Expand reusable components
- Template System: Create diagram templates for common patterns
- Configuration Tools: GUI tools for non-developers to create diagrams
- Performance Monitoring: Track rendering performance across diagram types
Integration Improvements
- Real-time Preview: Live parameter updates during template editing
- Validation Tools: Automatic parameter validation and error reporting
- Documentation Generation: Auto-generate parameter documentation
- Testing Automation: Automated visual regression testing