Overview
The Diagram Editor is a powerful visual tool for creating interactive water network schemas. Built with Konva.js, it allows you to draw custom diagrams with images, lines, text, and polylines, then overlay real-time data from InfluxDB.
Key Features
- Drawing Tools: Lines, polylines, text, and images
- Image Library: Pre-loaded water infrastructure icons
- Variable Binding: Attach InfluxDB variables to any element
- Real-time Overlays: Display live data on diagram elements
- Animated Lines: Flow direction indicators
- Zoom & Pan: Navigate large diagrams
- Layer Management: Send elements to front/back
- Auto-save: Persistent storage in backend
Editor Interface
Component Architecture
- Top Navbar: Save, clear, undo, zoom controls
- Left Sidebar: Drawing tool selection
- Canvas Area: Main drawing surface using Konva
- Style Panels: Configure line styles, text formatting
- Variable Panel: Assign InfluxDB variables
Drawing Tools
Line Tool
Draw simple straight lines:- Click “Line” in sidebar
- Click start point on canvas
- Click end point to complete
- Right-click to cancel
Polyline Tool
Draw multi-segment lines:- Click “Polyline” in sidebar
- Click to place each vertex
- Press Enter or double-click to finish
- Right-click to cancel
- Double-click on polyline to insert new vertex
- Vertices are draggable when selected
Text Tool
Add text labels:- Click “Text” in sidebar
- Click position on canvas
- Type text in popup editor
- Configure font size, color, style
Image Tool
Place infrastructure icons:- Click “Image” in sidebar
- Select from image library
- Image appears at center of canvas
- Drag to position, resize with handles
Variable Binding
Assigning Variables
Attach real-time data to diagram elements:- Select element on canvas
- Click “Assign Variable” in sidebar
- Choose InfluxDB variable from list
- Configure display position
Variable Configuration
Display Positions
Variable labels can be positioned relative to elements:- Arriba (Top): Above element
- Abajo (Bottom): Below element
- Izquierda (Left): Left side
- Derecha (Right): Right side
- Centro (Center): Centered on element
Line Animations
Lines display animated flow direction:Animation Loop
Inverting Animation
Toggle flow direction per line:Line Styling
Line Style Panel
Applying Styles
Text Editing
Text Editor Component
Editing Existing Text
Double-click text element to edit:Canvas Navigation
Zoom Controls
Mouse Wheel Zoom
Pan Mode
Toggle pan mode to drag the canvas:Layer Management
Send to Back
Bring to Front
Saving Diagrams
Save Flow
Element Serialization
Loading Diagrams
Keyboard Shortcuts
| Key | Action |
|---|---|
| Esc | Cancel current tool |
| Enter | Finish polyline |
| Delete | Delete selected element |
| Ctrl+Z | Undo last action |
Shortcut Implementation
Variable Overlays
Label Rendering
Variables display as floating labels:Boolean Color Configuration
For boolean variables, configure ON/OFF colors:Binary Bit Selection
For variables with binary fields:Custom Hooks
useDiagramState
Manages diagram elements and selection:useDrawingTools
Handles drawing tool logic:useTooltipManager
Manages variable overlay configuration:Performance Optimization
Batch Drawing
Konva automatically batches rendering:Lazy Loading Images
Images load on-demand:Use Cases
Water Distribution Schema
- Add tank images at source locations
- Draw polylines for pipe networks
- Add pump images at station locations
- Bind flow rate variables to pipes
- Bind level variables to tanks
- Add pressure sensor variables
Treatment Plant Layout
- Use building images for structures
- Draw flow lines between processes
- Add text labels for equipment names
- Bind process variables to equipment
- Use boolean indicators for valve states
Best Practices
Diagram Organization
Diagram Organization
- Use layers effectively (pipes behind, labels on top)
- Group related elements visually
- Use consistent colors for similar infrastructure
- Keep variable labels concise
Performance
Performance
- Limit diagrams to 100-150 elements
- Use simple images (PNG with transparency)
- Avoid excessive animation on many lines
- Save frequently during complex edits
Variable Binding
Variable Binding
- Only bind variables that need real-time display
- Use appropriate position for each element type
- Configure boolean colors to match UI theme
- Test variable updates before finalizing diagram
Troubleshooting
Elements Not Selectable
- Check element is not behind others (use layer controls)
- Verify transformer is properly attached
- Ensure element has unique ID
Variables Not Displaying
- Confirm variable is assigned to element
- Check
show: truein dataInflux config - Verify InfluxDB variable exists and has data
- Check position is not off-canvas
Performance Issues
- Reduce number of animated lines
- Simplify complex polylines
- Use lower resolution images
- Clear browser cache
Next Steps
Maps
Create geographic maps of infrastructure
Charts
Display diagram data in charts

