fix diagram
This commit is contained in:
parent
20f86a2176
commit
c56ec0d15b
2 changed files with 53 additions and 39 deletions
|
|
@ -29,48 +29,54 @@
|
||||||
<rect x="40" y="40" width="224.95000000000005" height="285" rx="0" ry="0" fill="var(--_group-fill)" stroke="var(--_node-stroke)" stroke-width="1" />
|
<rect x="40" y="40" width="224.95000000000005" height="285" rx="0" ry="0" fill="var(--_group-fill)" stroke="var(--_node-stroke)" stroke-width="1" />
|
||||||
<rect x="40" y="40" width="224.95000000000005" height="28" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="1" />
|
<rect x="40" y="40" width="224.95000000000005" height="28" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="1" />
|
||||||
<text x="52" y="54" dy="0.35em" font-size="12" font-weight="600" fill="var(--_text-sec)">Node1</text>
|
<text x="52" y="54" dy="0.35em" font-size="12" font-weight="600" fill="var(--_text-sec)">Node1</text>
|
||||||
<rect x="284.95000000000005" y="40" width="431.1" height="285" rx="0" ry="0" fill="var(--_group-fill)" stroke="var(--_node-stroke)" stroke-width="1" />
|
<rect x="284.95000000000005" y="40" width="431.09999999999997" height="285" rx="0" ry="0" fill="var(--_group-fill)" stroke="var(--_node-stroke)" stroke-width="1" />
|
||||||
<rect x="284.95000000000005" y="40" width="431.1" height="28" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="1" />
|
<rect x="284.95000000000005" y="40" width="431.09999999999997" height="28" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="1" />
|
||||||
<text x="296.95000000000005" y="54" dy="0.35em" font-size="12" font-weight="600" fill="var(--_text-sec)">Node2</text>
|
<text x="296.95000000000005" y="54" dy="0.35em" font-size="12" font-weight="600" fill="var(--_text-sec)">Node2</text>
|
||||||
<rect x="736.0500000000001" y="40" width="126.04999999999998" height="285" rx="0" ry="0" fill="var(--_group-fill)" stroke="var(--_node-stroke)" stroke-width="1" />
|
<rect x="736.05" y="40" width="126.05000000000007" height="285" rx="0" ry="0" fill="var(--_group-fill)" stroke="var(--_node-stroke)" stroke-width="1" />
|
||||||
<rect x="736.0500000000001" y="40" width="126.04999999999998" height="28" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="1" />
|
<rect x="736.05" y="40" width="126.05000000000007" height="28" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="1" />
|
||||||
<text x="748.0500000000001" y="54" dy="0.35em" font-size="12" font-weight="600" fill="var(--_text-sec)">Node3</text>
|
<text x="748.05" y="54" dy="0.35em" font-size="12" font-weight="600" fill="var(--_text-sec)">Node3</text>
|
||||||
<polyline points="99.45000000000005,132 99.45000000000005,287 120.6875,287" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
<polyline points="99.45000000000002,132 99.45000000000002,287 113.23750000000003,287" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
||||||
<polyline points="201.92499999999995,132 201.92499999999995,287 180.6875,287" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
<polyline points="201.92500000000004,132 201.92500000000004,287 188.13750000000005,287" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
||||||
<polyline points="150.6875,305 150.6875,442" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
<polyline points="150.68750000000003,305 150.68750000000003,460 427.30000000000007,460" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
||||||
<polyline points="150.6875,478 150.6875,615" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
<polyline points="482.62500000000006,478 482.62500000000006,615" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
||||||
|
<polyline points="482.62500000000006,305 482.62500000000006,442" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
||||||
<polyline points="358.70000000000005,132 358.70000000000005,287 445.17500000000007,287" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
<polyline points="358.70000000000005,132 358.70000000000005,287 445.17500000000007,287" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
||||||
<polyline points="482.62500000000006,132 482.62500000000006,269" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
<polyline points="482.62500000000006,132 482.62500000000006,269" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
||||||
<polyline points="624.4250000000001,132 624.4250000000001,287 520.075,287" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
<polyline points="624.425,132 624.425,287 520.075,287" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
||||||
|
<polyline points="799.075,305 799.075,460 537.95,460" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
||||||
<polyline points="799.075,132 799.075,269" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
<polyline points="799.075,132 799.075,269" fill="none" stroke="var(--_line)" stroke-width="0.75" marker-end="url(#arrowhead)" />
|
||||||
<rect x="82.87000000000005" y="187" width="33.16" height="27" rx="4" ry="4" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
|
<rect x="82.87000000000002" y="187" width="33.16" height="27" rx="4" ry="4" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
|
||||||
<text x="99.45000000000005" y="200.5" text-anchor="middle" dy="0.35em" font-size="11" font-weight="400" fill="var(--_text-muted)">i2c</text>
|
<text x="99.45000000000002" y="200.5" text-anchor="middle" dy="0.35em" font-size="11" font-weight="400" fill="var(--_text-muted)">i2c</text>
|
||||||
<rect x="182.48499999999996" y="187" width="38.88" height="27" rx="4" ry="4" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
|
<rect x="182.48500000000004" y="187" width="38.88" height="27" rx="4" ry="4" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
|
||||||
<text x="201.92499999999995" y="200.5" text-anchor="middle" dy="0.35em" font-size="11" font-weight="400" fill="var(--_text-muted)">uart</text>
|
<text x="201.92500000000004" y="200.5" text-anchor="middle" dy="0.35em" font-size="11" font-weight="400" fill="var(--_text-muted)">uart</text>
|
||||||
<rect x="114.0875" y="360" width="73.2" height="27" rx="4" ry="4" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
|
<rect x="114.08750000000003" y="360" width="73.2" height="27" rx="4" ry="4" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
|
||||||
<text x="150.6875" y="373.5" text-anchor="middle" dy="0.35em" font-size="11" font-weight="400" fill="var(--_text-muted)">Custom TCP</text>
|
<text x="150.68750000000003" y="373.5" text-anchor="middle" dy="0.35em" font-size="11" font-weight="400" fill="var(--_text-muted)">Custom TCP</text>
|
||||||
<rect x="131.2475" y="533" width="38.88" height="27" rx="4" ry="4" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
|
<rect x="463.18500000000006" y="533" width="38.88" height="27" rx="4" ry="4" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
|
||||||
<text x="150.6875" y="546.5" text-anchor="middle" dy="0.35em" font-size="11" font-weight="400" fill="var(--_text-muted)">mqtt</text>
|
<text x="482.62500000000006" y="546.5" text-anchor="middle" dy="0.35em" font-size="11" font-weight="400" fill="var(--_text-muted)">mqtt</text>
|
||||||
<rect x="95.3625" y="442" width="110.65" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
<rect x="446.02500000000003" y="360" width="73.2" height="27" rx="4" ry="4" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
|
||||||
<rect x="56.037499999999994" y="615" width="189.3" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
<text x="482.62500000000006" y="373.5" text-anchor="middle" dy="0.35em" font-size="11" font-weight="400" fill="var(--_text-muted)">Custom TCP</text>
|
||||||
<rect x="62.00000000000004" y="96" width="74.9" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
<rect x="762.475" y="360" width="73.2" height="27" rx="4" ry="4" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
|
||||||
<rect x="120.6875" y="269" width="60" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
<text x="799.075" y="373.5" text-anchor="middle" dy="0.35em" font-size="11" font-weight="400" fill="var(--_text-muted)">Custom TCP</text>
|
||||||
<rect x="160.89999999999995" y="96" width="82.05000000000001" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
<rect x="427.30000000000007" y="442" width="110.65" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
||||||
|
<rect x="387.975" y="615" width="189.3" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
||||||
|
<rect x="62.000000000000014" y="96" width="74.9" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
||||||
|
<rect x="113.23750000000003" y="269" width="74.9" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
||||||
|
<rect x="160.90000000000003" y="96" width="82.05000000000001" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
||||||
<rect x="306.95000000000005" y="96" width="103.5" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
<rect x="306.95000000000005" y="96" width="103.5" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
||||||
<rect x="445.17500000000007" y="269" width="74.9" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
<rect x="445.17500000000007" y="269" width="74.9" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
||||||
<rect x="434.45000000000005" y="96" width="96.35000000000001" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
<rect x="434.45000000000005" y="96" width="96.35000000000001" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
||||||
<rect x="554.8000000000001" y="96" width="139.25" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
<rect x="554.8" y="96" width="139.25" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
||||||
<rect x="758.0500000000001" y="96" width="82.05000000000001" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
<rect x="758.0500000000001" y="96" width="82.05000000000001" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
||||||
<rect x="761.625" y="269" width="74.9" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
<rect x="761.625" y="269" width="74.9" height="36" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="0.75" />
|
||||||
<text x="150.6875" y="460" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">Event Proxy</text>
|
<text x="482.62500000000006" y="460" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">Event Proxy</text>
|
||||||
<text x="150.6875" y="633" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">Home Assistant Servier</text>
|
<text x="482.625" y="633" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">Home Assistant Servier</text>
|
||||||
<text x="99.45000000000005" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">bme280</text>
|
<text x="99.45000000000002" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">bme280</text>
|
||||||
<text x="150.6875" y="287" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">mc1</text>
|
<text x="150.68750000000003" y="287" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">pico w</text>
|
||||||
<text x="201.92499999999995" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">pms5003</text>
|
<text x="201.92500000000004" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">pms5003</text>
|
||||||
<text x="358.70000000000005" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">Anemometer</text>
|
<text x="358.70000000000005" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">Anemometer</text>
|
||||||
<text x="482.62500000000006" y="287" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">pico w</text>
|
<text x="482.62500000000006" y="287" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">pico w</text>
|
||||||
<text x="482.62500000000006" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">Wind Vane</text>
|
<text x="482.62500000000006" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">Wind Vane</text>
|
||||||
<text x="624.4250000000001" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">MIPS Microphone</text>
|
<text x="624.425" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">MIPS Microphone</text>
|
||||||
<text x="799.075" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">ltr-559</text>
|
<text x="799.075" y="114" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">ltr-559</text>
|
||||||
<text x="799.075" y="287" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">pico w</text>
|
<text x="799.075" y="287" text-anchor="middle" dy="0.35em" font-size="13" font-weight="500" fill="var(--_text)">pico w</text>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 9.2 KiB |
|
|
@ -1,25 +1,33 @@
|
||||||
import { renderMermaid } from "beautiful-mermaid";
|
import { renderMermaid, renderMermaidAscii } from "beautiful-mermaid";
|
||||||
|
|
||||||
const diagram = await renderMermaid(`
|
// Parse command line arguments
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
const renderMode = args.includes("--ascii") ? "ascii" : "normal";
|
||||||
|
|
||||||
|
const diagram = `
|
||||||
flowchart TD
|
flowchart TD
|
||||||
subgraph Node1
|
subgraph Node1
|
||||||
bme280 -->|i2c| mc1
|
bme280 -->|i2c| mc1[pico w]
|
||||||
pms5003 -->|uart| mc1
|
pms5003 -->|uart| mc1
|
||||||
end
|
end
|
||||||
mc1[pico w] -->|Custom TCP| proxy[Event Proxy]
|
mc1 -->|Custom TCP| proxy[Event Proxy]
|
||||||
proxy -->|mqtt| ha[Home Assistant Servier]
|
proxy -->|mqtt| ha[Home Assistant Servier]
|
||||||
|
|
||||||
|
|
||||||
mc2[pico w] --> |Custom TCP| proxy
|
mc2[pico w] -->|Custom TCP| proxy
|
||||||
subgraph Node2
|
subgraph Node2
|
||||||
wind_speed[Anemometer] --> mc2
|
wind_speed[Anemometer] --> mc2
|
||||||
wind_dir[Wind Vane] --> mc2
|
wind_dir[Wind Vane] --> mc2
|
||||||
mic[MIPS Microphone] --> mc2
|
mic[MIPS Microphone] --> mc2
|
||||||
end
|
end
|
||||||
|
|
||||||
mc3[pico w] --> |Custom TCP| proxy
|
mc3[pico w] -->|Custom TCP| proxy
|
||||||
subgraph Node3
|
subgraph Node3
|
||||||
ltr-559 --> mc3
|
ltr-559 --> mc3
|
||||||
end
|
end`;
|
||||||
`);
|
|
||||||
console.log(diagram);
|
if (renderMode === "ascii") {
|
||||||
|
console.log(renderMermaidAscii(diagram));
|
||||||
|
} else {
|
||||||
|
console.log(await renderMermaid(diagram));
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue