plant-automation-js: Plant Automation (a diagram of automation symbols)
A diagram demo with symbols of its own: no backend, no network calls beyond
its own files. A <vn-diagram> with a <vn-diagram-palette> beside it and a
<vn-diagram-toolbar> above it, over the control layout of a small plant
(30 symbols, 29 connectors) loaded from plan.json through
VanillaDiagramStaticDataManager. The toolbar (the vanilla-diagram-toolbar
component, its own script) is written in markup: the default bar's items,
with Tidy up after the status line. Its connector type and arrows menus
restyle a selected connector (a bus line's arrowless look is "No arrows").
See
docs/vanilla-diagram/00-index.md.
What it shows
Three symbol sets of the app's own.
app.jsregistersdevices,equipmentandinterfaceswithVanillaDiagramElement.registerSymbolSet(), ten symbols each, and the palette shows them as three groups (sets="devices equipment interfaces"), then the connector kinds:Devices Equipment Interfaces SBEProximity sensorRIORemote I/OPBPush buttonLSLimit switchMCCMCC panelPB-ILLIlluminated push buttonYVGValve / Solenoid valveJBJunction boxPB-LATCHLatching push buttonMKLMotorLCLocal control boxSLSelector switchPTPressure transmitterCPOperator deskLEDIndicator lightTTTemperature sensorHMIHMI panelE-STOPEmergency stopPSPressure switchPLCPLCKSKey switchFSFlow switchSCSafety controllerBUZBuzzerLELevel sensorVFDInverter / DriveHMI-TSTouch screen HMIENCEncoderPNLElectrical panelJSJoystick / ManipulatorA tile's tooltip and accessible name are the symbol's label with its code, "Proximity sensor (SBE)".
Symbols drawn by a render callback. Every symbol is a card: the node's shape (a rounded rectangle the theme or the colour slot paints) with a pictogram centred in it, and the node's text (its tag,
PT-101) in a strip along the bottom, the symbol's text box. The pictograms are SVG paths in a 24-unit box that scales with the card;styles.csspaints them with the node's text colour, which every theme and colour slot sets to read on the node's fill. A node without text has no strip: its pictogram fills the card, which is how the palette's small tiles draw it.A colour slot per set.
app.jssets the palette'sswatchesmap from the set definitions: devices incol3, equipment incol2, interfaces incol6. The nodes inplan.jsoncarry the same slots, and the toolbar's colour menu changes a node's slot.A node starts with its code. A
vn-diagram-node-addinglistener gives a node added from the palette its symbol's code as text (E-STOP); edit it in place (double-click, Enter or F2) to add the number.The plan. A control row (HMI, PLC, safety controller, local control box, electrical panel, MCC), a distribution row (operator desk, remote I/O, junction box, drive) and a field row (the valve and the sensors on the junction box, the motor and its encoder on the drive), with the operator desk's interfaces in a column at its left and the local control box's above it. The connectors carry no arrowheads; a few have a label (Ethernet, Profinet, Safety bus, Power, Feedback). The elbows route around the shapes (
avoid-shapesis on by default): in this layout none has a shape in its way, so they draw the plain elbow until a shape is moved across one.Editing and the toolbar, as in process-flowchart-js: select, move, resize, connect by ports, edit text, copy and paste, undo and redo, zoom, colour, and download the drawing as
diagram.svganddiagram.png. The export keeps the pictograms with their colours. The status line at the toolbar's left shows each change's label fromvn-diagram-changed. Tidy up, beside it, is the standardlayoutcommand with a label: it arranges the plan as layers flowing down along the connectors (one undo step), then zooms to fit. The result differs from the hand-drawn rows: the operator desk's interfaces connect to it, so they go in the layer above it, and a straight connector runs at an angle once its ends no longer line up. Undo brings the rows back.Fourteen themes. The Theme selector sets one of the diagram's built-in themes, the grid's Default, Material, Fiori, Carbon, Glow, Fluent and Apple, light and dark, on the diagram, the palette and the toolbar, and swaps the page chrome's shared app theme (
../_common/themes/app-<theme>.css). The pictograms follow it: each theme colours the three sets' slots its own way.
Files
| File | |
|---|---|
index.html |
The header with the theme selector, the toolbar and its items (Tidy up, the standard commands), the palette and the diagram |
app.js |
The pictograms, the three sets and their render callback, the node codes, the status line, the theme switch, the load |
plan.json |
The plant's control layout: a version 1 diagram document, as toJSON() returns |
styles.css |
Layout, and the pictograms' paint; colours come from the shared app theme and the diagram's theme |
Running it
Serve the repository root (npx http-server . -p 4173) and open
/samples/plant-automation-js/. In the build, dist/samples/plant-automation-js/
loads vanilla-diagram.bundle.js and vanilla-diagram-toolbar.bundle.js from
dist/vanilla-components/latest/.