swimlane-diagram 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md ADDED
@@ -0,0 +1,188 @@
1
+ # swimlane-diagram
2
+
3
+ **English** | [日本語](./README.md)
4
+
5
+ A library that draws swimlane diagrams (cross-functional flowcharts) as SVG from a few lines of
6
+ plain text. **No dependencies, a single file**, and it runs both in the browser and in Node.js.
7
+
8
+ ![Example: from order to payment](docs/example.en.svg)
9
+
10
+ The diagram above is drawn from this text (`.swim`):
11
+
12
+ ```
13
+ swimlane
14
+ title "From order to payment"
15
+ direction TB
16
+
17
+ lane sales "Sales" #FFF1E0
18
+ lane back "Back office" #E6EFFC
19
+ lane ware "Warehouse" #E7F6EC
20
+
21
+ phase p1 "Intake"
22
+ phase p2 "Fulfillment"
23
+ phase p3 "Billing"
24
+
25
+ node s "Inquiry" lane=sales phase=p1 shape=startdot
26
+ node n1 "Send a quote" lane=sales phase=p1
27
+ node n2 "Take the order" lane=sales phase=p1 shape=io
28
+ node d1 "Credit approved?" lane=back phase=p1 shape=decision
29
+ node n3 "Revise the terms" lane=sales phase=p1 color=#FFE0E0
30
+ node n4 "Register the order" lane=back phase=p2
31
+ node d2 "In stock?" lane=ware phase=p2 shape=decision
32
+ node n5 "Order from supplier" lane=ware phase=p2 color=#FFF3D6
33
+ node n6 "Ship it" lane=ware phase=p2
34
+ node n7 "Send the invoice" lane=back phase=p3
35
+ node n8 "Confirm payment" lane=back phase=p3
36
+ node e "Done" lane=back phase=p3 shape=enddot
37
+
38
+ s -> n1
39
+ n1 -> n2
40
+ n2 -> d1 "Ask for review"
41
+ d1 -> n4 "OK"
42
+ d1 -> n3 "NG"
43
+ n3 -> n2 "Re-quote"
44
+ n4 -> d2 "Request shipment"
45
+ d2 -> n6 "Yes"
46
+ d2 -> n5 "No"
47
+ n5 -> n6 "On arrival"
48
+ n6 --> n7 "Shipment notice"
49
+ n7 -> n8
50
+ n8 -> e
51
+ ```
52
+
53
+ Put a node at the crossing of **who (lane) × when (phase)**, and the position and the route of every
54
+ line are worked out for you. You never write coordinates.
55
+
56
+ The example uses decisions (diamonds), a rework loop, input/output (parallelograms) and a dashed
57
+ line (a hand-off or a notice). Where lines cross, one **hops over** the other; where they merge, they
58
+ **curve into one**. So you can tell from the shape of a line alone whether it passes by or joins in.
59
+
60
+ ## Getting it
61
+
62
+ A single `swimlane.js` is all you need. There are three ways to get it.
63
+
64
+ ```
65
+ npm install swimlane-diagram
66
+ ```
67
+
68
+ ```html
69
+ <script src="https://cdn.jsdelivr.net/npm/swimlane-diagram@1.3.0/swimlane.js"></script>
70
+ ```
71
+
72
+ You can also drop [swimlane.js](swimlane.js) from this repository onto your own server.
73
+ **Pin the version** when you load it from a CDN (without `@1.3.0`, your diagram may look different
74
+ once the next release lands).
75
+
76
+ ### Browser
77
+
78
+ ```html
79
+ <script src="swimlane.js"></script>
80
+ <div id="diagram"></div>
81
+ <script>
82
+ Swimlane.renderTo('#diagram', `swimlane
83
+ lane a "Applicant"
84
+ node n1 "Submit a request" lane=a
85
+ node n2 "Approve it" lane=a
86
+ n1 -> n2`);
87
+ </script>
88
+ ```
89
+
90
+ ### Node.js
91
+
92
+ ```js
93
+ const Swimlane = require('swimlane-diagram'); // './swimlane.js' if you vendored the file
94
+
95
+ const result = Swimlane.render(code);
96
+ if (result.ok) {
97
+ fs.writeFileSync('diagram.svg', result.svg);
98
+ } else {
99
+ console.error(result.errors); // errors carry the line number
100
+ }
101
+ ```
102
+
103
+ Nothing here touches the DOM, so it works as-is in build scripts and static site generators.
104
+
105
+ ## Writing `.swim`
106
+
107
+ The first line is `swimlane`. Anything from `#` to the end of a line is a comment.
108
+
109
+ | Line | Meaning |
110
+ |---|---|
111
+ | `title "Order flow"` | Title of the diagram (optional) |
112
+ | `direction TB` | Flow direction: `TB` (vertical) or `LR` (horizontal). `TB` by default |
113
+ | `lane sales "Sales" #FFF1E0` | A lane (who does it). The trailing color is optional |
114
+ | `phase p1 "Intake"` | A phase (when it happens). Leave phases out for a lane-only diagram |
115
+ | `node n1 "Send a quote" lane=sales phase=p1` | A node. `lane` and `phase` decide where it sits |
116
+ | `n1 -> n2 "label"` | A link (solid). The label is optional |
117
+ | `n1 --> n2` | A link (dashed) |
118
+
119
+ Attributes a node can take:
120
+
121
+ | Attribute | Values |
122
+ |---|---|
123
+ | `lane=` / `phase=` | Lane id / phase id |
124
+ | `shape=` | `process` (default, rectangle) / `start` / `end` (rounded) / `decision` (diamond) / `io` (parallelogram) / `startdot` (●) / `enddot` (◉) |
125
+ | `color=` | `#RRGGBB`. Fill color of the node |
126
+
127
+ Values are read as whitespace-separated tokens, so a value itself cannot contain a space.
128
+
129
+ ## API
130
+
131
+ ```js
132
+ Swimlane.render(code) // → { ok, svg, errors }
133
+ Swimlane.renderTo(target, code) // draws into a selector or element → { ok, svg, errors }
134
+ ```
135
+
136
+ When you want finer control:
137
+
138
+ | Name | What it does |
139
+ |---|---|
140
+ | `parse(code)` | Parses `.swim` and returns `{ state, errors }` |
141
+ | `generate(state)` | Builds `.swim` back from a state (for GUI editors) |
142
+ | `computeLayout(state)` | Computes coordinates only; draws nothing |
143
+ | `drawSvg(state, layout)` | Produces the SVG string from a computed layout |
144
+ | `SHAPES` / `LINK_STYLES` | The available shapes and line styles |
145
+ | `VERSION` | Engine version |
146
+
147
+ Layout (`computeLayout`) and drawing (`drawSvg`) are separate, so you can replace the placement
148
+ logic alone and keep the rest.
149
+
150
+ ## About the SVG it produces
151
+
152
+ - No external CSS and no web fonts. Colors and typefaces are written into the SVG as attributes, so
153
+ it looks the same when loaded with `<img>` or converted to an image.
154
+ - A white rectangle sits under the diagram, so the background is never transparent.
155
+ - Nothing external is referenced, so a `<canvas>` stays untainted when you turn it into a PNG.
156
+
157
+ ## Related
158
+
159
+ | | |
160
+ |---|---|
161
+ | [Swimlane GUI Studio](https://tossie85.site/tools/swimlane-gui-studio.html) | A GUI editor in the browser. Build a diagram from forms and export `.swim` |
162
+ | [Swimlane GUI Studio (VS Code)](https://marketplace.visualstudio.com/items?itemName=tossie85.swimlane-gui-studio) | The same tool inside VS Code |
163
+ | [Swimlane Diagram Preview (VS Code)](https://marketplace.visualstudio.com/items?itemName=tossie85.swimlane-diagram-preview) | Renders ` ```swimlane ` blocks in the built-in Markdown preview |
164
+
165
+ ## Development
166
+
167
+ ```
168
+ npm test
169
+ ```
170
+
171
+ 39 checks run. They cover which side of a node a line leaves from and enters (out on the right and
172
+ bottom, in on the left and top), headers fitting inside their bands, labels never being crossed by
173
+ another line, crossings being distinguishable from merges — **properties that decide whether a
174
+ diagram can be read at a glance**. The example above (`examples/order.swim` and this English
175
+ version) goes through the same checks.
176
+
177
+ ```
178
+ npm run example
179
+ ```
180
+
181
+ Redraws the README figures (`docs/example.svg` and `docs/example.en.svg`) from `examples/`.
182
+ When the example changes, run this instead of editing the SVG by hand. The same diagram also
183
+ appears in the two VS Code extensions, where it ships as `docs/example*.png` — the Marketplace
184
+ does not accept SVG images.
185
+
186
+ ## License
187
+
188
+ [MIT](LICENSE)
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # swimlane-diagram
2
2
 
3
+ **日本語** | [English](./README.en.md)
4
+
3
5
  スイムレーン図(業務フロー図)を、短いテキストから SVG に描くライブラリです。
4
6
  **依存ライブラリなし・1ファイル**で、ブラウザでも Node.js でも動きます。
5
7
 
@@ -57,8 +59,18 @@ swimlane
57
59
 
58
60
  ## 使い方
59
61
 
60
- `swimlane.js` を1つ手元に置けば動きます(このリポジトリの
61
- [swimlane.js](swimlane.js) をそのまま使えます)。
62
+ `swimlane.js` を1つ手元に置けば動きます。入手の仕方は3つあります。
63
+
64
+ ```
65
+ npm install swimlane-diagram
66
+ ```
67
+
68
+ ```html
69
+ <script src="https://cdn.jsdelivr.net/npm/swimlane-diagram@1.3.0/swimlane.js"></script>
70
+ ```
71
+
72
+ このリポジトリの [swimlane.js](swimlane.js) をそのまま置いても構いません。
73
+ CDN は**版を固定して**読み込みます(`@1.3.0` を外すと、次の版が出たときに図が変わります)。
62
74
 
63
75
  ### ブラウザ
64
76
 
@@ -77,7 +89,7 @@ swimlane
77
89
  ### Node.js
78
90
 
79
91
  ```js
80
- const Swimlane = require('./swimlane.js');
92
+ const Swimlane = require('swimlane-diagram'); // 手元に置いた場合は './swimlane.js'
81
93
 
82
94
  const result = Swimlane.render(code);
83
95
  if (result.ok) {
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="788" height="1193" viewBox="0 0 788 1193" font-family="Inter, 'Yu Gothic UI', 'Meiryo UI', sans-serif"><rect x="0" y="0" width="788" height="1193" fill="#FFFFFF"></rect><text x="394" y="24" text-anchor="middle" font-size="16" font-weight="700" fill="#16233A">From order to payment</text><g transform="translate(14, 48)"><g data-pick="lane" data-idx="0"><rect class="sl-shape" x="132" y="0" width="204" height="1131" fill="#FFF1E0" fill-opacity="0.55" stroke="#B9C7DA"></rect><rect x="132" y="0" width="204" height="38" fill="#FFF1E0" stroke="#B9C7DA"></rect><text x="234" y="24" text-anchor="middle" font-size="12.5" font-weight="700" fill="#16233A">Sales</text></g><g data-pick="lane" data-idx="1"><rect class="sl-shape" x="336" y="0" width="204" height="1131" fill="#E6EFFC" fill-opacity="0.55" stroke="#B9C7DA"></rect><rect x="336" y="0" width="204" height="38" fill="#E6EFFC" stroke="#B9C7DA"></rect><text x="438" y="24" text-anchor="middle" font-size="12.5" font-weight="700" fill="#16233A">Back office</text></g><g data-pick="lane" data-idx="2"><rect class="sl-shape" x="540" y="0" width="204" height="1131" fill="#E7F6EC" fill-opacity="0.55" stroke="#B9C7DA"></rect><rect x="540" y="0" width="204" height="38" fill="#E7F6EC" stroke="#B9C7DA"></rect><text x="642" y="24" text-anchor="middle" font-size="12.5" font-weight="700" fill="#16233A">Warehouse</text></g><g data-pick="phase" data-idx="0"><rect class="sl-shape" x="0" y="38" width="132" height="396" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="241" text-anchor="middle" font-size="12" font-weight="700" fill="#3C516C">Intake</text></g><g data-pick="phase" data-idx="1"><rect class="sl-shape" x="0" y="460" width="132" height="358" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="644" text-anchor="middle" font-size="12" font-weight="700" fill="#3C516C">Fulfillment</text></g><g data-pick="phase" data-idx="2"><rect class="sl-shape" x="0" y="844" width="132" height="210" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="954" text-anchor="middle" font-size="12" font-weight="700" fill="#3C516C">Billing</text></g><g><path class="sl-hit" d="M 234 64 V 81 H 234 V 98" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="0"></path><path d="M 234 64 L 234 81 Q 234 81 234 81 L 234 81 Q 234 81 234 81 L 234 98" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="0"></path><polygon class="sl-arrow" points="234,98 229.66,91 238.34,91" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 234 156 V 167 H 234 V 178" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="1"></path><path d="M 234 156 L 234 167 Q 234 167 234 167 L 234 167 Q 234 167 234 167 L 234 178" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="1"></path><polygon class="sl-arrow" points="234,178 229.66,171 238.34,171" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 234 236 V 250 H 327 V 256 H 438 V 274" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="2"></path><path d="M 234 236 L 234 243 Q 234 250 241 250 L 324 250 Q 327 250 327 253 L 327 253 Q 327 256 330 256 L 335 256 Q 340 249 345 256 L 429 256 Q 438 256 438 265 L 438 274" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="2"></path><polygon class="sl-arrow" points="438,274 433.66,267 442.34,267" fill="#42506B"></polygon><rect x="231.07999999999998" y="241" width="94" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="2"></rect><text x="278.08" y="254" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="2">Ask for review</text></g><g><path class="sl-hit" d="M 522 303 H 540 V 454 H 438 V 466" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="3"></path><path d="M 522 303 L 531 303 Q 540 303 540 312 L 540 445 Q 540 454 531 454 L 444 454 Q 438 454 438 460 L 438 466" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="3"></path><polygon class="sl-arrow" points="438,466 433.66,459 442.34,459" fill="#42506B"></polygon><rect x="529" y="375.5" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="3"></rect><text x="540" y="388.5" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="3">OK</text></g><g><path class="sl-hit" d="M 438 332 V 351 H 234 V 370" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="4"></path><path d="M 438 332 L 438 342 Q 438 351 429 351 L 345 351 Q 340 344 335 351 L 243 351 Q 234 351 234 360 L 234 370" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="4"></path><polygon class="sl-arrow" points="234,370 229.66,363 238.34,363" fill="#42506B"></polygon><rect x="354.03999999999996" y="342" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="4"></rect><text x="365.03999999999996" y="355" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="4">NG</text></g><g><path class="sl-hit" d="M 318 399 H 340 V 207 H 318" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="5"></path><path d="M 318 399 L 331 399 Q 340 399 340 390 L 340 216 Q 340 207 331 207 L 318 207" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="5"></path><polygon class="sl-arrow" points="318,207 325,202.66 325,211.34" fill="#42506B"></polygon><rect x="291" y="294" width="58" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="5"></rect><text x="320" y="307" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="5">Re-quote</text></g><g><path class="sl-hit" d="M 438 524 V 538 H 531 V 544 H 642 V 562" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="6"></path><path d="M 438 524 L 438 531 Q 438 538 445 538 L 528 538 Q 531 538 531 541 L 531 541 Q 531 544 534 544 L 633 544 Q 642 544 642 553 L 642 562" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="6"></path><polygon class="sl-arrow" points="642,562 637.66,555 646.34,555" fill="#42506B"></polygon><rect x="462.96000000000004" y="529" width="106" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="6"></rect><text x="515.96" y="542" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="6">Request shipment</text></g><g><path class="sl-hit" d="M 726 591 H 744 V 742 H 642 V 754" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="7"></path><path d="M 726 591 L 735 591 Q 744 591 744 600 L 744 733 Q 744 742 735 742 L 648 742 Q 642 742 642 748 L 642 754" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="7"></path><polygon class="sl-arrow" points="642,754 637.66,747 646.34,747" fill="#42506B"></polygon><rect x="730" y="663.5" width="28" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="7"></rect><text x="744" y="676.5" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="7">Yes</text></g><g><path class="sl-hit" d="M 642 620 V 639 H 642 V 658" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="8"></path><path d="M 642 620 L 642 639 Q 642 639 642 639 L 642 639 Q 642 639 642 639 L 642 658" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="8"></path><polygon class="sl-arrow" points="642,658 637.66,651 646.34,651" fill="#42506B"></polygon><rect x="631" y="630" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="8"></rect><text x="642" y="643" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="8">No</text></g><g><path class="sl-hit" d="M 642 716 V 735 H 642 V 754" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="9"></path><path d="M 642 716 L 642 735 Q 642 735 642 735 L 642 735 Q 642 735 642 735 L 642 754" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="9"></path><polygon class="sl-arrow" points="642,754 637.66,747 646.34,747" fill="#42506B"></polygon><rect x="607" y="721.44" width="70" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="9"></rect><text x="642" y="734.44" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="9">On arrival</text></g><g><path class="sl-hit" d="M 642 812 V 826 H 549 V 832 H 438 V 850" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="10"></path><path d="M 642 812 L 642 819 Q 642 826 635 826 L 552 826 Q 549 826 549 829 L 549 829 Q 549 832 546 832 L 447 832 Q 438 832 438 841 L 438 850" fill="none" stroke="#42506B" stroke-width="1.6" stroke-dasharray="6 4" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="10"></path><polygon class="sl-arrow" points="438,850 433.66,843 442.34,843" fill="#42506B"></polygon><rect x="514.04" y="817" width="100" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="10"></rect><text x="564.04" y="830" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="10">Shipment notice</text></g><g><path class="sl-hit" d="M 438 908 V 919 H 438 V 930" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="11"></path><path d="M 438 908 L 438 919 Q 438 919 438 919 L 438 919 Q 438 919 438 919 L 438 930" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="11"></path><polygon class="sl-arrow" points="438,930 433.66,923 442.34,923" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 438 988 V 1005 H 438 V 1022" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="12"></path><path d="M 438 988 L 438 1005 Q 438 1005 438 1005 L 438 1005 Q 438 1005 438 1005 L 438 1022" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="12"></path><polygon class="sl-arrow" points="438,1022 433.66,1015 442.34,1015" fill="#42506B"></polygon></g><g data-pick="node" data-idx="1"><rect class="sl-shape" x="150" y="98" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="234" y="132" text-anchor="middle" font-size="12" fill="#16233A">Send a quote</text></g><g data-pick="node" data-idx="2"><polygon class="sl-shape" points="166,178 318,178 302,236 150,236" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="234" y="212" text-anchor="middle" font-size="12" fill="#16233A">Take the order</text></g><g data-pick="node" data-idx="4"><rect class="sl-shape" x="150" y="370" width="168" height="58" rx="7" ry="7" fill="#FFE0E0" stroke="#42506B" stroke-width="1.6"></rect><text x="234" y="404" text-anchor="middle" font-size="12" fill="#16233A">Revise the terms</text></g><g data-pick="node" data-idx="3"><polygon class="sl-shape" points="438,274 522,303 438,332 354,303" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="438" y="300.5" text-anchor="middle" font-size="12" fill="#16233A">Credit </text><text x="438" y="315.5" text-anchor="middle" font-size="12" fill="#16233A">approved?</text></g><g data-pick="node" data-idx="5"><rect class="sl-shape" x="354" y="466" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="492.5" text-anchor="middle" font-size="12" fill="#16233A">Register the </text><text x="438" y="507.5" text-anchor="middle" font-size="12" fill="#16233A">order</text></g><g data-pick="node" data-idx="9"><rect class="sl-shape" x="354" y="850" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="884" text-anchor="middle" font-size="12" fill="#16233A">Send the invoice</text></g><g data-pick="node" data-idx="10"><rect class="sl-shape" x="354" y="930" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="964" text-anchor="middle" font-size="12" fill="#16233A">Confirm payment</text></g><g data-pick="node" data-idx="6"><polygon class="sl-shape" points="642,562 726,591 642,620 558,591" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="642" y="596" text-anchor="middle" font-size="12" fill="#16233A">In stock?</text></g><g data-pick="node" data-idx="7"><rect class="sl-shape" x="558" y="658" width="168" height="58" rx="7" ry="7" fill="#FFF3D6" stroke="#42506B" stroke-width="1.6"></rect><text x="642" y="684.5" text-anchor="middle" font-size="12" fill="#16233A">Order from </text><text x="642" y="699.5" text-anchor="middle" font-size="12" fill="#16233A">supplier</text></g><g data-pick="node" data-idx="8"><rect class="sl-shape" x="558" y="754" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="642" y="788" text-anchor="middle" font-size="12" fill="#16233A">Ship it</text></g><g data-pick="node" data-idx="0"><circle class="sl-shape" cx="234" cy="51" r="13" fill="#42506B" stroke="#42506B" stroke-width="1.6"></circle><rect x="208" y="64" width="52" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect><text x="234" y="77" text-anchor="middle" font-size="11" fill="#3C516C">Inquiry</text></g><g data-pick="node" data-idx="11"><circle class="sl-shape" cx="438" cy="1035" r="13" fill="#42506B" stroke="#42506B" stroke-width="1.6"></circle><circle cx="438" cy="1035" r="9" fill="#FFFFFF"></circle><circle cx="438" cy="1035" r="6" fill="#42506B"></circle><rect x="421" y="1048" width="34" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect><text x="438" y="1061" text-anchor="middle" font-size="11" fill="#3C516C">Done</text></g></g></svg>
package/docs/example.svg CHANGED
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="790" height="1510" viewBox="0 0 790 1510" font-family="Inter, 'Yu Gothic UI', 'Meiryo UI', sans-serif"><rect x="0" y="0" width="790" height="1510" fill="#FFFFFF"></rect><text x="395" y="24" text-anchor="middle" font-size="16" font-weight="700" fill="#16233A">受注から入金までの流れ</text><g transform="translate(14, 48)"><g data-pick="lane" data-idx="0"><rect class="sl-shape" x="132" y="0" width="204" height="1448" fill="#FFF1E0" fill-opacity="0.55" stroke="#B9C7DA"></rect><rect x="132" y="0" width="204" height="38" fill="#FFF1E0" stroke="#B9C7DA"></rect><text x="234" y="24" text-anchor="middle" font-size="12.5" font-weight="700" fill="#16233A">営業</text></g><g data-pick="lane" data-idx="1"><rect class="sl-shape" x="336" y="0" width="204" height="1448" fill="#E6EFFC" fill-opacity="0.55" stroke="#B9C7DA"></rect><rect x="336" y="0" width="204" height="38" fill="#E6EFFC" stroke="#B9C7DA"></rect><text x="438" y="24" text-anchor="middle" font-size="12.5" font-weight="700" fill="#16233A">業務</text></g><g data-pick="lane" data-idx="2"><rect class="sl-shape" x="540" y="0" width="204" height="1448" fill="#E7F6EC" fill-opacity="0.55" stroke="#B9C7DA"></rect><rect x="540" y="0" width="204" height="38" fill="#E7F6EC" stroke="#B9C7DA"></rect><text x="642" y="24" text-anchor="middle" font-size="12.5" font-weight="700" fill="#16233A">倉庫</text></g><g data-pick="phase" data-idx="0"><rect class="sl-shape" x="0" y="38" width="132" height="541" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="313.5" text-anchor="middle" font-size="12" font-weight="700" fill="#3C516C">受付</text></g><g data-pick="phase" data-idx="1"><rect class="sl-shape" x="0" y="605" width="132" height="487" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="853.5" text-anchor="middle" font-size="12" font-weight="700" fill="#3C516C">出荷</text></g><g data-pick="phase" data-idx="2"><rect class="sl-shape" x="0" y="1161" width="132" height="210" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="1271" text-anchor="middle" font-size="12" font-weight="700" fill="#3C516C">請求</text></g><g><path class="sl-hit" d="M 234 64 V 81 H 234 V 98" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="0"></path><path d="M 234 64 L 234 81 Q 234 81 234 81 L 234 81 Q 234 81 234 81 L 234 98" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="0"></path><polygon class="sl-arrow" points="234,98 229.66,91 238.34,91" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 234 156 V 196.5 H 234 V 237" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="1"></path><path d="M 234 156 L 234 196.5 Q 234 196.5 234 196.5 L 234 196.5 Q 234 196.5 234 196.5 L 234 237" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="1"></path><polygon class="sl-arrow" points="234,237 229.66,230 238.34,230" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 234 295 V 309 H 327 V 358 H 438 V 376" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="2"></path><path d="M 234 295 L 234 302 Q 234 309 241 309 L 318 309 Q 327 309 327 318 L 327 349 Q 327 358 333 358 L 335 358 Q 340 351 345 358 L 429 358 Q 438 358 438 367 L 438 376" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="2"></path><polygon class="sl-arrow" points="438,376 433.66,369 442.34,369" fill="#42506B"></polygon><rect x="267.3" y="300" width="65" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="2"></rect><text x="299.8" y="313" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="2">審査を依頼</text></g><g><path class="sl-hit" d="M 522 405 H 540 V 599 H 438 V 611" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="3"></path><path d="M 522 405 L 531 405 Q 540 405 540 414 L 540 590 Q 540 599 531 599 L 444 599 Q 438 599 438 605 L 438 611" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="3"></path><polygon class="sl-arrow" points="438,611 433.66,604 442.34,604" fill="#42506B"></polygon><rect x="529" y="499" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="3"></rect><text x="540" y="512" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="3">OK</text></g><g><path class="sl-hit" d="M 438 434 V 474.5 H 234 V 515" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="4"></path><path d="M 438 434 L 438 465.5 Q 438 474.5 429 474.5 L 345 474.5 Q 340 467.5 335 474.5 L 243 474.5 Q 234 474.5 234 483.5 L 234 515" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="4"></path><polygon class="sl-arrow" points="234,515 229.66,508 238.34,508" fill="#42506B"></polygon><rect x="359.2" y="465.5" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="4"></rect><text x="370.2" y="478.5" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="4">NG</text></g><g><path class="sl-hit" d="M 318 544 H 340 V 266 H 318" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="5"></path><path d="M 318 544 L 331 544 Q 340 544 340 535 L 340 275 Q 340 266 331 266 L 318 266" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="5"></path><polygon class="sl-arrow" points="318,266 325,261.66 325,270.34" fill="#42506B"></polygon><rect x="318.5" y="535" width="43" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="5"></rect><text x="340" y="548" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="5">再見積</text></g><g><path class="sl-hit" d="M 438 669 V 683 H 531 V 732 H 642 V 750" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="6"></path><path d="M 438 669 L 438 676 Q 438 683 445 683 L 522 683 Q 531 683 531 692 L 531 723 Q 531 732 540 732 L 633 732 Q 642 732 642 741 L 642 750" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="6"></path><polygon class="sl-arrow" points="642,750 637.66,743 646.34,743" fill="#42506B"></polygon><rect x="498.5" y="732" width="65" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="6"></rect><text x="531" y="745" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="6">出荷を指示</text></g><g><path class="sl-hit" d="M 726 779 H 744 V 1016 H 642 V 1028" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="7"></path><path d="M 726 779 L 735 779 Q 744 779 744 788 L 744 1007 Q 744 1016 735 1016 L 648 1016 Q 642 1016 642 1022 L 642 1028" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="7"></path><polygon class="sl-arrow" points="642,1028 637.66,1021 646.34,1021" fill="#42506B"></polygon><rect x="728" y="894.5" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="7"></rect><text x="744" y="907.5" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="7">あり</text></g><g><path class="sl-hit" d="M 642 808 V 848.5 H 642 V 889" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="8"></path><path d="M 642 808 L 642 848.5 Q 642 848.5 642 848.5 L 642 848.5 Q 642 848.5 642 848.5 L 642 889" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="8"></path><polygon class="sl-arrow" points="642,889 637.66,882 646.34,882" fill="#42506B"></polygon><rect x="626" y="839.5" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="8"></rect><text x="642" y="852.5" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="8">なし</text></g><g><path class="sl-hit" d="M 642 947 V 987.5 H 642 V 1028" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="9"></path><path d="M 642 947 L 642 987.5 Q 642 987.5 642 987.5 L 642 987.5 Q 642 987.5 642 987.5 L 642 1028" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="9"></path><polygon class="sl-arrow" points="642,1028 637.66,1021 646.34,1021" fill="#42506B"></polygon><rect x="620.5" y="978.5" width="43" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="9"></rect><text x="642" y="991.5" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="9">入荷後</text></g><g><path class="sl-hit" d="M 642 1086 V 1100 H 549 V 1149 H 438 V 1167" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="10"></path><path d="M 642 1086 L 642 1093 Q 642 1100 635 1100 L 558 1100 Q 549 1100 549 1109 L 549 1140 Q 549 1149 540 1149 L 447 1149 Q 438 1149 438 1158 L 438 1167" fill="none" stroke="#42506B" stroke-width="1.6" stroke-dasharray="6 4" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="10"></path><polygon class="sl-arrow" points="438,1167 433.66,1160 442.34,1160" fill="#42506B"></polygon><rect x="516.5" y="1149" width="65" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="10"></rect><text x="549" y="1162" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="10">出荷を通知</text></g><g><path class="sl-hit" d="M 438 1225 V 1236 H 438 V 1247" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="11"></path><path d="M 438 1225 L 438 1236 Q 438 1236 438 1236 L 438 1236 Q 438 1236 438 1236 L 438 1247" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="11"></path><polygon class="sl-arrow" points="438,1247 433.66,1240 442.34,1240" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 438 1305 V 1322 H 438 V 1339" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="12"></path><path d="M 438 1305 L 438 1322 Q 438 1322 438 1322 L 438 1322 Q 438 1322 438 1322 L 438 1339" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="12"></path><polygon class="sl-arrow" points="438,1339 433.66,1332 442.34,1332" fill="#42506B"></polygon></g><g data-pick="node" data-idx="1"><rect class="sl-shape" x="150" y="98" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="234" y="132" text-anchor="middle" font-size="12" fill="#16233A">見積を出す</text></g><g data-pick="node" data-idx="2"><polygon class="sl-shape" points="166,237 318,237 302,295 150,295" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="234" y="271" text-anchor="middle" font-size="12" fill="#16233A">注文を受ける</text></g><g data-pick="node" data-idx="4"><rect class="sl-shape" x="150" y="515" width="168" height="58" rx="7" ry="7" fill="#FFE0E0" stroke="#42506B" stroke-width="1.6"></rect><text x="234" y="549" text-anchor="middle" font-size="12" fill="#16233A">条件を見直す</text></g><g data-pick="node" data-idx="3"><polygon class="sl-shape" points="438,376 522,405 438,434 354,405" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="438" y="402.5" text-anchor="middle" font-size="12" fill="#16233A">与信は足りる</text><text x="438" y="417.5" text-anchor="middle" font-size="12" fill="#16233A">か</text></g><g data-pick="node" data-idx="5"><rect class="sl-shape" x="354" y="611" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="645" text-anchor="middle" font-size="12" fill="#16233A">受注を登録する</text></g><g data-pick="node" data-idx="9"><rect class="sl-shape" x="354" y="1167" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="1201" text-anchor="middle" font-size="12" fill="#16233A">請求書を送る</text></g><g data-pick="node" data-idx="10"><rect class="sl-shape" x="354" y="1247" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="1281" text-anchor="middle" font-size="12" fill="#16233A">入金を確認する</text></g><g data-pick="node" data-idx="6"><polygon class="sl-shape" points="642,750 726,779 642,808 558,779" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="642" y="784" text-anchor="middle" font-size="12" fill="#16233A">在庫はあるか</text></g><g data-pick="node" data-idx="7"><rect class="sl-shape" x="558" y="889" width="168" height="58" rx="7" ry="7" fill="#FFF3D6" stroke="#42506B" stroke-width="1.6"></rect><text x="642" y="923" text-anchor="middle" font-size="12" fill="#16233A">取り寄せる</text></g><g data-pick="node" data-idx="8"><rect class="sl-shape" x="558" y="1028" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="642" y="1062" text-anchor="middle" font-size="12" fill="#16233A">出荷する</text></g><g data-pick="node" data-idx="0"><circle class="sl-shape" cx="234" cy="51" r="13" fill="#42506B" stroke="#42506B" stroke-width="1.6"></circle><rect x="218" y="64" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect><text x="234" y="77" text-anchor="middle" font-size="11" fill="#3C516C">引合</text></g><g data-pick="node" data-idx="11"><circle class="sl-shape" cx="438" cy="1352" r="13" fill="#42506B" stroke="#42506B" stroke-width="1.6"></circle><circle cx="438" cy="1352" r="9" fill="#FFFFFF"></circle><circle cx="438" cy="1352" r="6" fill="#42506B"></circle><rect x="422" y="1365" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect><text x="438" y="1378" text-anchor="middle" font-size="11" fill="#3C516C">完了</text></g></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="790" height="1193" viewBox="0 0 790 1193" font-family="Inter, 'Yu Gothic UI', 'Meiryo UI', sans-serif"><rect x="0" y="0" width="790" height="1193" fill="#FFFFFF"></rect><text x="395" y="24" text-anchor="middle" font-size="16" font-weight="700" fill="#16233A">受注から入金までの流れ</text><g transform="translate(14, 48)"><g data-pick="lane" data-idx="0"><rect class="sl-shape" x="132" y="0" width="204" height="1131" fill="#FFF1E0" fill-opacity="0.55" stroke="#B9C7DA"></rect><rect x="132" y="0" width="204" height="38" fill="#FFF1E0" stroke="#B9C7DA"></rect><text x="234" y="24" text-anchor="middle" font-size="12.5" font-weight="700" fill="#16233A">営業</text></g><g data-pick="lane" data-idx="1"><rect class="sl-shape" x="336" y="0" width="204" height="1131" fill="#E6EFFC" fill-opacity="0.55" stroke="#B9C7DA"></rect><rect x="336" y="0" width="204" height="38" fill="#E6EFFC" stroke="#B9C7DA"></rect><text x="438" y="24" text-anchor="middle" font-size="12.5" font-weight="700" fill="#16233A">業務</text></g><g data-pick="lane" data-idx="2"><rect class="sl-shape" x="540" y="0" width="204" height="1131" fill="#E7F6EC" fill-opacity="0.55" stroke="#B9C7DA"></rect><rect x="540" y="0" width="204" height="38" fill="#E7F6EC" stroke="#B9C7DA"></rect><text x="642" y="24" text-anchor="middle" font-size="12.5" font-weight="700" fill="#16233A">倉庫</text></g><g data-pick="phase" data-idx="0"><rect class="sl-shape" x="0" y="38" width="132" height="396" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="241" text-anchor="middle" font-size="12" font-weight="700" fill="#3C516C">受付</text></g><g data-pick="phase" data-idx="1"><rect class="sl-shape" x="0" y="460" width="132" height="358" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="644" text-anchor="middle" font-size="12" font-weight="700" fill="#3C516C">出荷</text></g><g data-pick="phase" data-idx="2"><rect class="sl-shape" x="0" y="844" width="132" height="210" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="954" text-anchor="middle" font-size="12" font-weight="700" fill="#3C516C">請求</text></g><g><path class="sl-hit" d="M 234 64 V 81 H 234 V 98" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="0"></path><path d="M 234 64 L 234 81 Q 234 81 234 81 L 234 81 Q 234 81 234 81 L 234 98" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="0"></path><polygon class="sl-arrow" points="234,98 229.66,91 238.34,91" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 234 156 V 167 H 234 V 178" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="1"></path><path d="M 234 156 L 234 167 Q 234 167 234 167 L 234 167 Q 234 167 234 167 L 234 178" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="1"></path><polygon class="sl-arrow" points="234,178 229.66,171 238.34,171" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 234 236 V 250 H 327 V 256 H 438 V 274" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="2"></path><path d="M 234 236 L 234 243 Q 234 250 241 250 L 324 250 Q 327 250 327 253 L 327 253 Q 327 256 330 256 L 335 256 Q 340 249 345 256 L 429 256 Q 438 256 438 265 L 438 274" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="2"></path><polygon class="sl-arrow" points="438,274 433.66,267 442.34,267" fill="#42506B"></polygon><rect x="260.1" y="241" width="65" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="2"></rect><text x="292.6" y="254" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="2">審査を依頼</text></g><g><path class="sl-hit" d="M 522 303 H 540 V 454 H 438 V 466" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="3"></path><path d="M 522 303 L 531 303 Q 540 303 540 312 L 540 445 Q 540 454 531 454 L 444 454 Q 438 454 438 460 L 438 466" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="3"></path><polygon class="sl-arrow" points="438,466 433.66,459 442.34,459" fill="#42506B"></polygon><rect x="529" y="375.5" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="3"></rect><text x="540" y="388.5" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="3">OK</text></g><g><path class="sl-hit" d="M 438 332 V 351 H 234 V 370" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="4"></path><path d="M 438 332 L 438 342 Q 438 351 429 351 L 345 351 Q 340 344 335 351 L 243 351 Q 234 351 234 360 L 234 370" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="4"></path><polygon class="sl-arrow" points="234,370 229.66,363 238.34,363" fill="#42506B"></polygon><rect x="354.03999999999996" y="342" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="4"></rect><text x="365.03999999999996" y="355" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="4">NG</text></g><g><path class="sl-hit" d="M 318 399 H 340 V 207 H 318" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="5"></path><path d="M 318 399 L 331 399 Q 340 399 340 390 L 340 216 Q 340 207 331 207 L 318 207" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="5"></path><polygon class="sl-arrow" points="318,207 325,202.66 325,211.34" fill="#42506B"></polygon><rect x="306.5" y="294" width="43" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="5"></rect><text x="328" y="307" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="5">再見積</text></g><g><path class="sl-hit" d="M 438 524 V 538 H 531 V 544 H 642 V 562" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="6"></path><path d="M 438 524 L 438 531 Q 438 538 445 538 L 528 538 Q 531 538 531 541 L 531 541 Q 531 544 534 544 L 633 544 Q 642 544 642 553 L 642 562" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="6"></path><polygon class="sl-arrow" points="642,562 637.66,555 646.34,555" fill="#42506B"></polygon><rect x="483.46000000000004" y="529" width="65" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="6"></rect><text x="515.96" y="542" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="6">出荷を指示</text></g><g><path class="sl-hit" d="M 726 591 H 744 V 742 H 642 V 754" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="7"></path><path d="M 726 591 L 735 591 Q 744 591 744 600 L 744 733 Q 744 742 735 742 L 648 742 Q 642 742 642 748 L 642 754" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="7"></path><polygon class="sl-arrow" points="642,754 637.66,747 646.34,747" fill="#42506B"></polygon><rect x="728" y="631.92" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="7"></rect><text x="744" y="644.92" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="7">あり</text></g><g><path class="sl-hit" d="M 642 620 V 639 H 642 V 658" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="8"></path><path d="M 642 620 L 642 639 Q 642 639 642 639 L 642 639 Q 642 639 642 639 L 642 658" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="8"></path><polygon class="sl-arrow" points="642,658 637.66,651 646.34,651" fill="#42506B"></polygon><rect x="626" y="630" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="8"></rect><text x="642" y="643" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="8">なし</text></g><g><path class="sl-hit" d="M 642 716 V 735 H 642 V 754" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="9"></path><path d="M 642 716 L 642 735 Q 642 735 642 735 L 642 735 Q 642 735 642 735 L 642 754" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="9"></path><polygon class="sl-arrow" points="642,754 637.66,747 646.34,747" fill="#42506B"></polygon><rect x="620.5" y="721.44" width="43" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="9"></rect><text x="642" y="734.44" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="9">入荷後</text></g><g><path class="sl-hit" d="M 642 812 V 826 H 549 V 832 H 438 V 850" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="10"></path><path d="M 642 812 L 642 819 Q 642 826 635 826 L 552 826 Q 549 826 549 829 L 549 829 Q 549 832 546 832 L 447 832 Q 438 832 438 841 L 438 850" fill="none" stroke="#42506B" stroke-width="1.6" stroke-dasharray="6 4" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="10"></path><polygon class="sl-arrow" points="438,850 433.66,843 442.34,843" fill="#42506B"></polygon><rect x="531.54" y="817" width="65" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="10"></rect><text x="564.04" y="830" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="10">出荷を通知</text></g><g><path class="sl-hit" d="M 438 908 V 919 H 438 V 930" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="11"></path><path d="M 438 908 L 438 919 Q 438 919 438 919 L 438 919 Q 438 919 438 919 L 438 930" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="11"></path><polygon class="sl-arrow" points="438,930 433.66,923 442.34,923" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 438 988 V 1005 H 438 V 1022" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="12"></path><path d="M 438 988 L 438 1005 Q 438 1005 438 1005 L 438 1005 Q 438 1005 438 1005 L 438 1022" fill="none" stroke="#42506B" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="12"></path><polygon class="sl-arrow" points="438,1022 433.66,1015 442.34,1015" fill="#42506B"></polygon></g><g data-pick="node" data-idx="1"><rect class="sl-shape" x="150" y="98" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="234" y="132" text-anchor="middle" font-size="12" fill="#16233A">見積を出す</text></g><g data-pick="node" data-idx="2"><polygon class="sl-shape" points="166,178 318,178 302,236 150,236" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="234" y="212" text-anchor="middle" font-size="12" fill="#16233A">注文を受ける</text></g><g data-pick="node" data-idx="4"><rect class="sl-shape" x="150" y="370" width="168" height="58" rx="7" ry="7" fill="#FFE0E0" stroke="#42506B" stroke-width="1.6"></rect><text x="234" y="404" text-anchor="middle" font-size="12" fill="#16233A">条件を見直す</text></g><g data-pick="node" data-idx="3"><polygon class="sl-shape" points="438,274 522,303 438,332 354,303" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="438" y="300.5" text-anchor="middle" font-size="12" fill="#16233A">与信は足りる</text><text x="438" y="315.5" text-anchor="middle" font-size="12" fill="#16233A">か</text></g><g data-pick="node" data-idx="5"><rect class="sl-shape" x="354" y="466" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="500" text-anchor="middle" font-size="12" fill="#16233A">受注を登録する</text></g><g data-pick="node" data-idx="9"><rect class="sl-shape" x="354" y="850" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="884" text-anchor="middle" font-size="12" fill="#16233A">請求書を送る</text></g><g data-pick="node" data-idx="10"><rect class="sl-shape" x="354" y="930" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="964" text-anchor="middle" font-size="12" fill="#16233A">入金を確認する</text></g><g data-pick="node" data-idx="6"><polygon class="sl-shape" points="642,562 726,591 642,620 558,591" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="642" y="596" text-anchor="middle" font-size="12" fill="#16233A">在庫はあるか</text></g><g data-pick="node" data-idx="7"><rect class="sl-shape" x="558" y="658" width="168" height="58" rx="7" ry="7" fill="#FFF3D6" stroke="#42506B" stroke-width="1.6"></rect><text x="642" y="692" text-anchor="middle" font-size="12" fill="#16233A">取り寄せる</text></g><g data-pick="node" data-idx="8"><rect class="sl-shape" x="558" y="754" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="642" y="788" text-anchor="middle" font-size="12" fill="#16233A">出荷する</text></g><g data-pick="node" data-idx="0"><circle class="sl-shape" cx="234" cy="51" r="13" fill="#42506B" stroke="#42506B" stroke-width="1.6"></circle><rect x="218" y="64" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect><text x="234" y="77" text-anchor="middle" font-size="11" fill="#3C516C">引合</text></g><g data-pick="node" data-idx="11"><circle class="sl-shape" cx="438" cy="1035" r="13" fill="#42506B" stroke="#42506B" stroke-width="1.6"></circle><circle cx="438" cy="1035" r="9" fill="#FFFFFF"></circle><circle cx="438" cy="1035" r="6" fill="#42506B"></circle><rect x="422" y="1048" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect><text x="438" y="1061" text-anchor="middle" font-size="11" fill="#3C516C">完了</text></g></g></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swimlane-diagram",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Render swimlane (cross-functional) flowcharts as SVG from a small plain-text format. Zero dependencies, single file, works in the browser and in Node.",
5
5
  "keywords": [
6
6
  "swimlane",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "https://github.com/Tossie85/swimlane-diagram.git"
20
+ "url": "git+https://github.com/Tossie85/swimlane-diagram.git"
21
21
  },
22
22
  "license": "MIT",
23
23
  "author": "Tossie85",
@@ -25,8 +25,10 @@
25
25
  "files": [
26
26
  "swimlane.js",
27
27
  "README.md",
28
+ "README.en.md",
28
29
  "LICENSE",
29
- "docs/example.svg"
30
+ "docs/example.svg",
31
+ "docs/example.en.svg"
30
32
  ],
31
33
  "scripts": {
32
34
  "example": "node build/make-example.js",
package/swimlane.js CHANGED
@@ -82,9 +82,18 @@ function quote(s){
82
82
  }
83
83
  /* 接続ラベルのおおよその表示幅(px)。ラベル背景の白丸角パネルの実際の幅と合わせて使う。
84
84
  全角文字は半角の約2倍として概算する(等幅ではないので目安値)。 */
85
+ /* 接続ラベルの白い箱の高さ。描画と間隔の計算で同じ値を使う */
86
+ const LABEL_BOX_H = 18;
85
87
  function labelPixelWidth(label){
86
88
  return [...String(label || '')].reduce((n, ch) => n + (/[\x00-\xff]/.test(ch) ? 6 : 11), 0) + 10;
87
89
  }
90
+ /* 接続ラベルが「流れの向き」に要する大きさ(px)。
91
+ LR では文字の長さがそのまま効くが、TB では箱の高さ(18px)しか要らない。
92
+ ここを取り違えると、長いラベルが1つあるだけでフェーズ全体の段が間延びする。 */
93
+ function labelMainExtent(label, dir){
94
+ return dir === 'LR' ? labelPixelWidth(label) + 16 : LABEL_BOX_H + 20;
95
+ }
96
+
88
97
  /* 見出し(レーン名・フェーズ名)のおおよその表示幅(px)。
89
98
  太字なので、全角はフォントサイズとほぼ同じ幅、半角はその約6割として概算する。 */
90
99
  function headerTextWidth(label, fontSize){
@@ -683,30 +692,45 @@ function computeLayout(state){
683
692
  const ap = state.phases.length ? (A.phaseId || phases[0].id) : '__all';
684
693
  const bp = state.phases.length ? (B.phaseId || phases[0].id) : '__all';
685
694
  const aj = phases.findIndex(p=> p.id === ap), bj = phases.findIndex(p=> p.id === bp);
686
- if((aj === j && bj === j + 1) || (aj === j + 1 && bj === j)) need = Math.max(need, labelPixelWidth(e.label) + 16);
695
+ if((aj === j && bj === j + 1) || (aj === j + 1 && bj === j)) need = Math.max(need, labelMainExtent(e.label, dir));
687
696
  });
688
697
  if(need) gapAfter[j] = Math.max(gapAfter[j], need);
689
698
  }
690
699
 
691
- // フェーズ内にラベル付きの接続があると、流れ方向の間隔を広げてラベルの前後に棒を出す(要求1.2)。
692
- // こちらも同様に、ラベルの実際の表示幅から必要な間隔を求める(要求1.2)。
693
- const phaseGap = phases.map(p=>{
694
- let need = L.gapInner;
700
+ /* 段と段の隙間は、その隙間を実際に何が通るかで決める(フェーズ内で一律にしない)。
701
+ ラベル付きの接続がまたぐ隙間だけを広げ、何も通らない隙間は gapInner のまま詰める。
702
+ 一律にしていた頃は、長いラベルが1つあるだけでフェーズ全体が間延びしていた
703
+ (英語版の Intake が 110px、ラベルの無い Billing が 22px で、同じ図の中で揃わなかった)。 */
704
+ const phaseGapAt = phases.map((p, j)=>{
705
+ const gaps = new Array(Math.max(0, phaseRuns[j] - 1)).fill(L.gapInner);
706
+ if(!gaps.length) return gaps;
695
707
  state.links.forEach(e=>{
696
708
  if(!e.label) return;
697
709
  const A = state.nodes.find(n=> n.id === e.from), B = state.nodes.find(n=> n.id === e.to);
698
710
  if(!A || !B) return;
699
711
  const ap = state.phases.length ? (A.phaseId || phases[0].id) : '__all';
700
712
  const bp = state.phases.length ? (B.phaseId || phases[0].id) : '__all';
701
- if(ap === p.id && bp === p.id) need = Math.max(need, labelPixelWidth(e.label) + 16);
713
+ if(ap !== p.id || bp !== p.id) return;
714
+ const pa = nodePos.get(A.id), pb = nodePos.get(B.id);
715
+ if(!pa || !pb) return;
716
+ const lo = Math.min(pa.flow, pb.flow), hi = Math.max(pa.flow, pb.flow);
717
+ const need = labelMainExtent(e.label, dir);
718
+ // 同じ段どうし(lo === hi)はレーンの間を横に走るので、段の隙間には関係しない
719
+ for(let r = lo; r < hi && r < gaps.length; r++) gaps[r] = Math.max(gaps[r], need);
702
720
  });
703
- return need;
721
+ return gaps;
722
+ });
723
+ // フェーズの先頭から各段までの距離。隙間が段ごとに違うので足し上げて持つ
724
+ const phaseOffsets = phases.map((p, j)=>{
725
+ const offs = [0];
726
+ for(let r = 1; r < phaseRuns[j]; r++) offs.push(offs[r - 1] + nodeMain + phaseGapAt[j][r - 1]);
727
+ return offs;
704
728
  });
705
729
 
706
730
  const phaseBands = [];
707
731
  let main = mainStart;
708
732
  phases.forEach((p, j)=>{
709
- let size = phaseRuns[j] * nodeMain + (phaseRuns[j] - 1) * phaseGap[j];
733
+ let size = phaseOffsets[j][phaseRuns[j] - 1] + nodeMain;
710
734
  // LRではフェーズ名が上の細い帯(高さ38px固定)に横書きで入る。縦には広げられないので、
711
735
  // 名前が帯より長いときは帯の長さ(流れ方向)を広げる。広げないとはみ出して切れる。
712
736
  if(hasPhaseHeader && dir === 'LR') size = Math.max(size, headerTextWidth(p.label, 12) + 16);
@@ -735,7 +759,7 @@ function computeLayout(state){
735
759
  const list = cell.get(key(l.id, p.id)) || [];
736
760
  list.forEach((n)=>{
737
761
  const { flow: col, cross: row } = nodePos.get(n.id);
738
- const mainPos = phaseBands[j].start + col * (nodeMain + phaseGap[j]);
762
+ const mainPos = phaseBands[j].start + (phaseOffsets[j][col] != null ? phaseOffsets[j][col] : col * (nodeMain + L.gapInner));
739
763
  const crossPos = band.start + L.gapCross + row * (nodeCross + L.gapCross);
740
764
  const slot = dir === 'LR'
741
765
  ? { x: mainPos, y: crossPos, w: L.nodeW, h: L.nodeH }
@@ -1582,6 +1606,7 @@ function drawSvg(state){
1582
1606
  const segsOf = new Map();
1583
1607
  linkRenders.forEach(item=>{ if(item) segsOf.set(item.i, pathSegmentsOf(item.p.d)); });
1584
1608
  const placedBoxes = [];
1609
+ const nodeBoxes = lay.boxes.map(b=> ({ x:b.x, y:b.y, w:b.w, h:b.h }));
1585
1610
  linkRenders.forEach(item=>{
1586
1611
  if(!item || !item.e.label) return;
1587
1612
  const others = [];
@@ -1589,16 +1614,38 @@ function drawSvg(state){
1589
1614
  const clear = (mid)=>{
1590
1615
  const box = labelBoxOf(mid, item.e.label);
1591
1616
  if(others.some(([x1, y1, x2, y2])=> segHitsBox(x1, y1, x2, y2, box))) return false;
1617
+ // ノードの箱に重なると、図形の文字とラベルが混ざって読めなくなる
1618
+ if(nodeBoxes.some(b=> overlaps(box, b))) return false;
1592
1619
  return !placedBoxes.some(b=> overlaps(box, b));
1593
1620
  };
1594
1621
  let mid = item.p.mid;
1595
1622
  if(mid && !clear(mid)){
1596
- // 真ん中から外側へ、少しずつ離れた位置を試す。最初に空いた所へ置く。
1597
1623
  const own = segsOf.get(item.i) || [];
1598
- for(const t of [0.38, 0.62, 0.28, 0.72, 0.2, 0.8]){
1624
+ // 1) まず経路に沿って前後へずらす。線の上に載ったままなので、見た目がいちばん素直
1625
+ let found = null;
1626
+ for(const t of [0.38, 0.62, 0.3, 0.7, 0.24, 0.76, 0.18, 0.82, 0.12, 0.88]){
1599
1627
  const cand = pointAt(own, t);
1600
- if(cand && clear(cand)){ mid = cand; break; }
1628
+ if(cand && clear(cand)){ found = cand; break; }
1629
+ }
1630
+ // 2) それでも空かないときは、経路から横へ少しだけ外す。
1631
+ // 戻りの辺のように、ノードのすぐ脇を通る線はどこへずらしても箱に重なるため
1632
+ // (英語版の「Re-quote」が「Revise the terms」に7px重なっていた)。
1633
+ if(!found){
1634
+ for(const off of [12, -12, 20, -20, 30, -30, 42, -42]){
1635
+ for(const seg of own){
1636
+ const [x1, y1, x2, y2] = seg;
1637
+ const horiz = Math.abs(y1 - y2) < 0.5;
1638
+ for(const u of [0.5, 0.35, 0.65, 0.25, 0.75]){
1639
+ const px = x1 + (x2 - x1) * u, py = y1 + (y2 - y1) * u;
1640
+ const cand = horiz ? { x:px, y:py + off } : { x:px + off, y:py };
1641
+ if(clear(cand)){ found = cand; break; }
1642
+ }
1643
+ if(found) break;
1644
+ }
1645
+ if(found) break;
1646
+ }
1601
1647
  }
1648
+ if(found) mid = found;
1602
1649
  }
1603
1650
  if(mid){
1604
1651
  item.p.mid = mid;
@@ -1754,7 +1801,7 @@ function renderTo(target, code){
1754
1801
  }
1755
1802
 
1756
1803
  return {
1757
- VERSION: '1.2.1',
1804
+ VERSION: '1.3.0',
1758
1805
  SHAPES,
1759
1806
  LINK_STYLES,
1760
1807
  isDot,