GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - synergycodes/ng-diagram-electric-circuit: Angular schematic capture editor for circuit diagrams — drag-and-drop electronic components, wiring, and DXF/SVG/JPEG/JSON export. Built on ng-diagram.

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.vscode
.vscode
 
 
docs/assets
docs/assets
 
 
public
public
 
 
src
src
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.prettierignore
.prettierignore
 
 
.prettierrc
.prettierrc
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
angular.json
angular.json
 
 
eslint.config.js
eslint.config.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.app.json
tsconfig.app.json
 
 
tsconfig.json
tsconfig.json
 
 
tsconfig.spec.json
tsconfig.spec.json
 
 
vitest.config.ts
vitest.config.ts
 
 

Repository files navigation

ngDiagram Circuit Editor Template

License: MIT

Live demo: ngdiagram.dev/templates/electric-circuit

Circuit editor — drag a capacitor and a ground from the library, wire them, draw a wire from the capacitor into an existing wire to create a junction, reshape the wire, export to DXF

Interactive circuit / schematic editor built with Angular and ngDiagram. Use this project as a starting point for building your own schematic capture tool, node-based editor, or component-library-driven diagram. Lean dependencies: Angular, ngDiagram, and html-to-image (for JPEG export) — no opinionated third-party UI libraries.

Features:

  • Drag-and-drop component placement from a searchable, categorized library palette
  • A data-driven component catalog (resistor, capacitor, inductor, potentiometer, fuse, crystal, diode, LED, Zener, NPN/PNP transistors, NE555, switch, push button, battery, +5V, ground) rendered as crisp inline SVG
  • Free-form canvas: move, select, rotate, and wire components port-to-port
  • Orthogonal wire editing — reshape wires by dragging their segments, with grid snapping and port-anchored ends
  • Wire junctions (link-to-link) — drop or drag a wire onto another to create a solder-dot junction; branch from a wire, with junction port routing, merge-on-delete, and cleanup of orphaned junctions
  • Right-click context menus — copy / cut / paste / delete / rotate ±90° on a node, paste on the background
  • Export dropdown: DXF (vector, for AutoCAD / BricsCAD / LibreCAD — with layer mapping and text styles), editable SVG, JPEG snapshot of the canvas, or JSON (components + connections)
  • Properties sidebar with per-component-type specification fields (diagram-to-UI integration)
  • Minimap and zoom controls; full-height library / properties rails
  • Dark / light theme matching a dedicated design token system
  • Unique reference designators (R1, R2, C1…) auto-assigned on drop

Component library

Category Components
Passive Resistor, Capacitor, Inductor, Potentiometer, Fuse, Crystal
Semiconductors Diode, LED, Zener diode, NPN transistor, PNP transistor
Integrated circuits NE555
Electromechanical Switch, Push button
Power & Ground Battery, +5V source, GND

The library is fully data-driven: every component is one entry in component-catalog.ts describing its symbol size, connection ports, reference prefix, default value, and editable specification fields. Add a new component by adding a catalog entry and a @case to the symbol component.

Getting Started

Built against Angular 19.2 and ngDiagram 1.3 (see package.json); Node.js 18.19+, 20.11+ or 22 and npm 10+.

git clone https://github.com/synergycodes/ng-diagram-electric-circuit.git
cd ng-diagram-electric-circuit
npm install
npm start

Open http://localhost:4200 — a sample circuit loads: the classic NE555 astable multivibrator blinking an LED at about 1 Hz (13 components, 4 junctions, 19 wires). Try dragging a resistor from the library onto the canvas, wiring it into the circuit, then dropping a wire onto another wire to create a junction; right-click a component to rotate it. The sample circuit is seed data — replace it in diagram/data.ts.

Scripts

Script Description
npm start Start the dev server (ng serve)
npm run build Production build (ng build)
npm run watch Development build in watch mode
npm test Run unit tests (Vitest)
npm run lint Lint with ESLint (ng lint)
npm run format Format sources with Prettier
npm run format:check Check formatting without writing

ngDiagram APIs demonstrated

Concern API Where in this repo
Bootstrap provideNgDiagram() pages/circuit-editor-page.component.ts
Diagram surface <ng-diagram>, <ng-diagram-background> diagram/diagram.component.html
Node template NgDiagramNodeTemplate, NgDiagramNodeTemplateMap diagram/diagram.component.ts, diagram/node/circuit-node.component.ts
Edge template NgDiagramEdgeTemplate, NgDiagramEdgeTemplateMap, NgDiagramBaseEdgeComponent diagram/diagram.component.ts, diagram/wire/wire.component.ts
Ports <ng-diagram-port> diagram/node/circuit-node.component.html, diagram/wire/junction/node.component.ts
Palette (drag/drop) <ng-diagram-palette-item>, <ng-diagram-palette-item-preview>, paletteItemDropped library-sidebar/components/palette-tile/palette-tile.component.ts, diagram/diagram.component.html
Minimap <ng-diagram-minimap> minimap-bar/minimap-bar.component.html
Model initializeModel(), NgDiagramModelService (getConnectedEdges, awaitable addEdges) diagram/diagram.component.ts, diagram/wire/junction/topology/
Selection NgDiagramSelectionService diagram/editor-actions.service.ts
Viewport NgDiagramViewportService (awaitable zoomToFit, zoom, scale) diagram/diagram.component.ts, diagram/editor-actions.service.ts
Linking config NgDiagramConfig.linking (validateConnection, finalEdgeDataBuilder) diagram/diagram.component.ts
Edge routing NgDiagramConfig.edgeRouting (orthogonal) + routingMode: 'manual' for reshaped wires diagram/diagram.component.ts, diagram/wire/interactions/reshape/
Middleware createMiddlewares() — custom junction port-routing middleware diagram/diagram.component.ts
Events diagramInit, edgeDrawEnded, selectionMoved, selectionRemoved diagram/diagram.component.html

Architecture

src/
├── circuit-theme.css                 # --ce-* color tokens (dark/light) + ng-diagram var remap
├── typography.css                    # Poppins type scale
└── app/circuit-editor/
    ├── circuit-editor.config.ts       # injectable editor config (viewport)
    ├── pages/                         # page shell: canvas + overlays
    ├── diagram/
    │   ├── diagram.component.*        # ng-diagram host, template maps, palette-drop
    │   ├── data.ts                    # seed example circuit
    │   ├── editor-actions.service.ts  # clipboard / delete / rotate (context-menu actions)
    │   ├── model/                     # ComponentType, CircuitNodeData, catalog, guards, connectivity
    │   ├── node/
    │   │   ├── circuit-node.component.* # one template for every component
    │   │   └── symbols/               # inline-SVG schematic symbols
    │   └── wire/                      # everything about wires/links
    │       ├── wire.component.*        # edge (wire) template
    │       ├── geometry/              # pure orthogonal-polyline math + hit testing
    │       ├── pointer-drag-controller.ts # shared gesture plumbing
    │       ├── junction/              # solder-dot node + topology/ + routing/
    │       └── interactions/          # reshape, stretch, branch-from-wire, link-drop-preview
    ├── library-sidebar/               # searchable component palette
    ├── properties-sidebar/            # selection-driven properties form
    ├── minimap-bar/                   # bottom-right zoom + collapsible minimap
    ├── context-menu/                  # node & background right-click menus
    ├── export/                        # DXF + SVG + JPEG + JSON export (service + dropdown)
    └── top-navbar/                    # logo, filename, export, theme toggle

Design tokens

Every color is a --ce-* token defined per theme in circuit-theme.css, taken straight from the Figma color sheets (names and values for both dark and light modes). The base --ngd-* tokens ship with ngDiagram itself, so that file only adds the --ce-* tokens and remaps the few --ngd-* variables that drive the on-canvas look — grid background (major line every 10 minor cells), violet port rings, and the white-50% wire stroke.

Customization

  • Add a component: add an entry to COMPONENT_CATALOG and a @case in ComponentSymbolComponent. The palette tile, on-canvas node, and properties form pick it up automatically.
  • Change the seed circuit: edit data.ts.
  • Tune the viewport: edit CIRCUIT_EDITOR_DEFAULTS (zoom-to-fit padding, zoom step) in circuit-editor.config.ts, or override the CIRCUIT_EDITOR_CONFIG token in the page providers.
  • Theme: adjust the --ce-* tokens in circuit-theme.css.

Export format

export.service.ts offers four formats: DXF (vector, with layer mapping and text styles, for AutoCAD / BricsCAD / LibreCAD — renderers in export/dxf-circuit/), an editable SVG (vector schematic built from the model, black-on-white for print), a JPEG raster snapshot of the canvas, and JSON. The JSON is a documented ng-diagram-circuit document — a components array (type, reference, value, specs, position, rotation) plus a connections array (port-to-port). The connectivity standard for circuits is a SPICE netlist, but these generic illustrative components don't map cleanly to SPICE device cards, so a clean JSON format is used instead.

Known limitations / notes

  • Composite components: the catalog ships single-primitive components only. Composite parts (e.g. a bridge rectifier — an assembly of diodes plus internal wiring) are out of scope, since each catalog entry maps to one schematic symbol.

Tech stack

  • Angular 19 (standalone, signals, zoneless via provideExperimentalZonelessChangeDetection)
  • ngDiagram (ng-diagram on npm)
  • html-to-image (JPEG export)
  • Plain CSS with a custom design-token system (no UI framework)
  • Poppins (Google Fonts)

Support

  • Issues: GitHub Issues
  • ngDiagram Discussions: GitHub Discussions, Discord
  • ngDiagram Documentation: ngdiagram.dev/docs

License

MIT — see LICENSE.


Built with ❤️ by the Synergy Codes team

About

Angular schematic capture editor for circuit diagrams — drag-and-drop electronic components, wiring, and DXF/SVG/JPEG/JSON export. Built on ng-diagram.

www.ngdiagram.dev/templates/electric-circuit/

Topics

angularcircuitcircuit-designcircuit-diagramdiagram-editordrag-and-dropdxfedaeda-softwareelectronic-design-automationelectronicsnetlistng-diagramnode-editorschematicschematic-captureschematic-editorstarter-templatetypescript

Resources

Readme
MIT license

Code of conduct

Code of conduct
Activity
Custom properties

Stars

4 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.