swimlane-diagram 1.2.1 → 1.4.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,207 @@
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" color=#D32F2F
43
+ n3 --> n2 "Re-quote" color=#D32F2F
44
+ n4 => d2 "Request shipment"
45
+ d2 => n6 "Yes"
46
+ d2 ==> n5 "No" color=#1565C0
47
+ n5 --> n6 "On arrival" color=#1565C0
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 and input/output (parallelograms). It also
57
+ uses all four line types: a **thick solid line for the main path**, a red dashed one for the rework
58
+ loop, a blue one for the detour taken when stock runs out, and a thin dashed one for a notice.
59
+ Thickness comes from `=>` and `==>`, colour from `color=`. Where lines cross, one **hops over** the other; where they merge, they
60
+ **curve into one**. So you can tell from the shape of a line alone whether it passes by or joins in.
61
+
62
+ ## Getting it
63
+
64
+ A single `swimlane.js` is all you need. There are three ways to get it.
65
+
66
+ ```
67
+ npm install swimlane-diagram
68
+ ```
69
+
70
+ ```html
71
+ <script src="https://cdn.jsdelivr.net/npm/swimlane-diagram@1.4.0/swimlane.js"></script>
72
+ ```
73
+
74
+ You can also drop [swimlane.js](swimlane.js) from this repository onto your own server.
75
+ **Pin the version** when you load it from a CDN (without `@1.4.0`, your diagram may look different
76
+ once the next release lands).
77
+
78
+ ### Browser
79
+
80
+ ```html
81
+ <script src="swimlane.js"></script>
82
+ <div id="diagram"></div>
83
+ <script>
84
+ Swimlane.renderTo('#diagram', `swimlane
85
+ lane a "Applicant"
86
+ node n1 "Submit a request" lane=a
87
+ node n2 "Approve it" lane=a
88
+ n1 -> n2`);
89
+ </script>
90
+ ```
91
+
92
+ ### Node.js
93
+
94
+ ```js
95
+ const Swimlane = require('swimlane-diagram'); // './swimlane.js' if you vendored the file
96
+
97
+ const result = Swimlane.render(code);
98
+ if (result.ok) {
99
+ fs.writeFileSync('diagram.svg', result.svg);
100
+ } else {
101
+ console.error(result.errors); // errors carry the line number
102
+ }
103
+ ```
104
+
105
+ Nothing here touches the DOM, so it works as-is in build scripts and static site generators.
106
+
107
+ ## Writing `.swim`
108
+
109
+ The first line is `swimlane`. Anything from `#` to the end of a line is a comment.
110
+
111
+ | Line | Meaning |
112
+ |---|---|
113
+ | `title "Order flow"` | Title of the diagram (optional) |
114
+ | `direction TB` | Flow direction: `TB` (vertical) or `LR` (horizontal). `TB` by default |
115
+ | `lane sales "Sales" #FFF1E0` | A lane (who does it). The trailing color is optional |
116
+ | `phase p1 "Intake"` | A phase (when it happens). Leave phases out for a lane-only diagram |
117
+ | `node n1 "Send a quote" lane=sales phase=p1` | A node. `lane` and `phase` decide where it sits |
118
+ | `n1 -> n2 "label"` | A link (solid). The label is optional |
119
+ | `n1 --> n2` | A link (dashed) |
120
+ | `n1 => n2` | A link (thick solid) |
121
+ | `n1 ==> n2` | A link (thick dashed) |
122
+
123
+ One line means solid, two mean dashed; `=` makes it thick. Spaces around the arrow are optional
124
+ (`n1-->n2` reads the same). A line may join only two nodes, so `n1 -> n2 -> n3` is an error.
125
+
126
+ > **Different from Mermaid.** In Mermaid flowcharts `-->` is solid and `==>` is thick solid.
127
+ > swimlane-diagram follows the rule above (one line solid, two lines dashed), so both mean the
128
+ > opposite of what they mean in Mermaid. These are different formats, and we are not reconciling them.
129
+
130
+ Attributes a node can take:
131
+
132
+ | Attribute | Values |
133
+ |---|---|
134
+ | `lane=` / `phase=` | Lane id / phase id |
135
+ | `shape=` | `process` (default, rectangle) / `start` / `end` (rounded) / `decision` (diamond) / `io` (parallelogram) / `startdot` (●) / `enddot` (◉) |
136
+ | `color=` | `#RRGGBB`. Fill color of the node |
137
+
138
+ Attributes a link can take:
139
+
140
+ | Attribute | Values |
141
+ |---|---|
142
+ | `color=` | `#RRGGBB`. Color of the line and its arrowhead, and of the label box border. `#42506B` by default |
143
+
144
+ Values are read as whitespace-separated tokens, so a value itself cannot contain a space.
145
+
146
+ ## API
147
+
148
+ ```js
149
+ Swimlane.render(code) // → { ok, svg, errors }
150
+ Swimlane.renderTo(target, code) // draws into a selector or element → { ok, svg, errors }
151
+ ```
152
+
153
+ When you want finer control:
154
+
155
+ | Name | What it does |
156
+ |---|---|
157
+ | `parse(code)` | Parses `.swim` and returns `{ state, errors }` |
158
+ | `generate(state)` | Builds `.swim` back from a state (for GUI editors) |
159
+ | `computeLayout(state)` | Computes coordinates only; draws nothing |
160
+ | `drawSvg(state, layout)` | Produces the SVG string from a computed layout |
161
+ | `SHAPES` / `LINK_STYLES` | The available shapes and line styles |
162
+ | `LINK_COLOR` | The default line color (`#42506B`) |
163
+ | `VERSION` | Engine version |
164
+
165
+ Layout (`computeLayout`) and drawing (`drawSvg`) are separate, so you can replace the placement
166
+ logic alone and keep the rest.
167
+
168
+ ## About the SVG it produces
169
+
170
+ - No external CSS and no web fonts. Colors and typefaces are written into the SVG as attributes, so
171
+ it looks the same when loaded with `<img>` or converted to an image.
172
+ - A white rectangle sits under the diagram, so the background is never transparent.
173
+ - Nothing external is referenced, so a `<canvas>` stays untainted when you turn it into a PNG.
174
+
175
+ ## Related
176
+
177
+ | | |
178
+ |---|---|
179
+ | [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` |
180
+ | [Swimlane GUI Studio (VS Code)](https://marketplace.visualstudio.com/items?itemName=tossie85.swimlane-gui-studio) | The same tool inside VS Code |
181
+ | [Swimlane Diagram Preview (VS Code)](https://marketplace.visualstudio.com/items?itemName=tossie85.swimlane-diagram-preview) | Renders ` ```swimlane ` blocks in the built-in Markdown preview |
182
+
183
+ ## Development
184
+
185
+ ```
186
+ npm test
187
+ ```
188
+
189
+ 109 checks run. They cover which side of a node a line leaves from and enters (out on the right and
190
+ bottom, in on the left and top), headers fitting inside their bands, phase bands keeping their
191
+ inner padding, labels never being crossed by
192
+ another line, crossings being distinguishable from merges — **properties that decide whether a
193
+ diagram can be read at a glance**. The example above (`examples/order.swim` and this English
194
+ version) goes through the same checks.
195
+
196
+ ```
197
+ npm run example
198
+ ```
199
+
200
+ Redraws the README figures (`docs/example.svg` and `docs/example.en.svg`) from `examples/`.
201
+ When the example changes, run this instead of editing the SVG by hand. The same diagram also
202
+ appears in the two VS Code extensions, where it ships as `docs/example*.png` — the Marketplace
203
+ does not accept SVG images.
204
+
205
+ ## License
206
+
207
+ [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
 
@@ -34,31 +36,44 @@ swimlane
34
36
  node e "完了" lane=back phase=p3 shape=enddot
35
37
 
36
38
  s -> n1
37
- n1 -> n2
38
- n2 -> d1 "審査を依頼"
39
- d1 -> n4 "OK"
40
- d1 -> n3 "NG"
41
- n3 -> n2 "再見積"
42
- n4 -> d2 "出荷を指示"
43
- d2 -> n6 "あり"
44
- d2 -> n5 "なし"
45
- n5 -> n6 "入荷後"
39
+ n1 => n2
40
+ n2 => d1 "審査を依頼"
41
+ d1 => n4 "OK"
42
+ d1 ==> n3 "NG" color=#D32F2F
43
+ n3 --> n2 "再見積" color=#D32F2F
44
+ n4 => d2 "出荷を指示"
45
+ d2 => n6 "あり"
46
+ d2 ==> n5 "なし" color=#1565C0
47
+ n5 --> n6 "入荷後" color=#1565C0
46
48
  n6 --> n7 "出荷を通知"
47
- n7 -> n8
49
+ n7 => n8
48
50
  n8 -> e
49
51
  ```
50
52
 
51
53
  **誰が(レーン)× いつ(フェーズ)** の交点にノードを置くと、位置と線の通り道は
52
54
  自動で決まります。座標を書く必要はありません。
53
55
 
54
- 上の図には、判断(ひし形)・差し戻し・入出力(平行四辺形)・破線(連絡や書類の受け渡し)が入っています。
56
+ 上の図には、判断(ひし形)・差し戻し・入出力(平行四辺形)が入っています。
57
+ 線は4種を使い分けています。**太い実線が本筋**、赤い破線が差し戻し(与信が足りない)、
58
+ 青い破線が在庫が無いときの迂回、細い破線が連絡(出荷を通知)です。
59
+ 太さは `=>` と `==>`、色は `color=` で指定します。
55
60
  線が交わる所は**またいで**通り過ぎ、合流する所は**カーブで寄り添って**1本になります。
56
61
  通り抜けているのか、集まっているのかが、線の形だけで分かります。
57
62
 
58
63
  ## 使い方
59
64
 
60
- `swimlane.js` を1つ手元に置けば動きます(このリポジトリの
61
- [swimlane.js](swimlane.js) をそのまま使えます)。
65
+ `swimlane.js` を1つ手元に置けば動きます。入手の仕方は3つあります。
66
+
67
+ ```
68
+ npm install swimlane-diagram
69
+ ```
70
+
71
+ ```html
72
+ <script src="https://cdn.jsdelivr.net/npm/swimlane-diagram@1.4.0/swimlane.js"></script>
73
+ ```
74
+
75
+ このリポジトリの [swimlane.js](swimlane.js) をそのまま置いても構いません。
76
+ CDN は**版を固定して**読み込みます(`@1.4.0` を外すと、次の版が出たときに図が変わります)。
62
77
 
63
78
  ### ブラウザ
64
79
 
@@ -77,7 +92,7 @@ swimlane
77
92
  ### Node.js
78
93
 
79
94
  ```js
80
- const Swimlane = require('./swimlane.js');
95
+ const Swimlane = require('swimlane-diagram'); // 手元に置いた場合は './swimlane.js'
81
96
 
82
97
  const result = Swimlane.render(code);
83
98
  if (result.ok) {
@@ -102,6 +117,16 @@ DOM に依存しないので、ビルドスクリプトや静的サイトの生
102
117
  | `node n1 "見積を出す" lane=sales phase=p1` | ノード。`lane` と `phase` で置き場所を決める |
103
118
  | `n1 -> n2 "ラベル"` | 接続(実線)。ラベルは省略可 |
104
119
  | `n1 --> n2` | 接続(破線) |
120
+ | `n1 => n2` | 接続(太い実線) |
121
+ | `n1 ==> n2` | 接続(太い破線) |
122
+
123
+ 線が1本なら実線、2本なら破線。`=` にすると太くなります。
124
+ 矢印の前後の空白は、あっても無くてもかまいません(`n1-->n2` でも読めます)。
125
+ 1行でつなげられるのは2つまでで、`n1 -> n2 -> n3` はエラーになります。
126
+
127
+ > **Mermaid との違い。** Mermaid のフローチャートでは `-->` が実線、`==>` が太い実線です。
128
+ > swimlane-diagram は上の規則(線1本=実線、2本=破線)を通すので、どちらも Mermaid とは
129
+ > 逆の意味になります。もともと別の記法なので、ここは合わせていません。
105
130
 
106
131
  ノードに付けられる属性:
107
132
 
@@ -111,6 +136,12 @@ DOM に依存しないので、ビルドスクリプトや静的サイトの生
111
136
  | `shape=` | `process`(既定・四角) / `start` / `end`(角丸) / `decision`(ひし形) / `io`(平行四辺形) / `startdot`(●) / `enddot`(◉) |
112
137
  | `color=` | `#RRGGBB`。ノードの塗り |
113
138
 
139
+ 接続に付けられる属性:
140
+
141
+ | 属性 | 値 |
142
+ |---|---|
143
+ | `color=` | `#RRGGBB`。線と矢じりの色。ラベルの箱の枠にも使われます。省略すると `#42506B` |
144
+
114
145
  ## API
115
146
 
116
147
  ```js
@@ -127,6 +158,7 @@ Swimlane.renderTo(target, code) // セレクタか要素に描画して → { o
127
158
  | `computeLayout(state)` | 座標だけを計算する。描画は含まない |
128
159
  | `drawSvg(state, layout)` | 計算済みのレイアウトから SVG 文字列を作る |
129
160
  | `SHAPES` / `LINK_STYLES` | 選べる図形・線種の一覧 |
161
+ | `LINK_COLOR` | 線の既定色(`#42506B`) |
130
162
  | `VERSION` | エンジンのバージョン |
131
163
 
132
164
  レイアウト計算(`computeLayout`)と描画(`drawSvg`)は分かれているので、
@@ -153,9 +185,10 @@ Swimlane.renderTo(target, code) // セレクタか要素に描画して → { o
153
185
  npm test
154
186
  ```
155
187
 
156
- 39件の検証が走ります。線の出入りする辺の使い分け(出力は右・下、入力は左・上)、
157
- 見出しが帯からはみ出していないこと、ラベルの上を他の線が通らないこと、
188
+ 109件の検証が走ります。線の出入りする辺の使い分け(出力は右・下、入力は左・上)、
189
+ 見出しが帯からはみ出していないこと、フェーズの帯に余白があること、ラベルの上を他の線が通らないこと、
158
190
  交差と合流が見分けられることなど、**図の読みやすさに直結する性質**を確かめています。
191
+ 線の記法については、`parse → generate → parse` の往復で意味が変わらないことも見ています。
159
192
  上の図(`examples/order.swim` と、その英語版)そのものも、この検証を通しています。
160
193
 
161
194
  ```
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="788" height="1162" viewBox="0 0 788 1162" font-family="Inter, 'Yu Gothic UI', 'Meiryo UI', sans-serif"><rect x="0" y="0" width="788" height="1162" 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="1100" 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="1100" 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="1100" 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><line x1="132" y1="464" x2="744" y2="464" stroke="#D3E1EF" stroke-width="1"></line><line x1="132" y1="848" x2="744" y2="848" stroke="#D3E1EF" stroke-width="1"></line><g data-pick="phase" data-idx="0"><rect class="sl-shape" x="0" y="38" width="132" height="426" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="256" 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="464" width="132" height="384" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="661" 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="848" width="132" height="252" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="979" text-anchor="middle" font-size="12" font-weight="700" fill="#3C516C">Billing</text></g><g><path class="sl-hit" d="M 234 81 V 98 H 234 V 115" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="0"></path><path d="M 234 81 L 234 98 Q 234 98 234 98 L 234 98 Q 234 98 234 98 L 234 115" 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,115 229.66,108 238.34,108" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 234 173 V 184 H 234 V 195" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="1"></path><path d="M 234 173 L 234 184 Q 234 184 234 184 L 234 184 Q 234 184 234 184 L 234 195" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="1"></path><polygon class="sl-arrow" points="234,195 228.42,186 239.58,186" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 234 253 V 267 H 327 V 273 H 438 V 291" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="2"></path><path d="M 234 253 L 234 260 Q 234 267 241 267 L 324 267 Q 327 267 327 270 L 327 270 Q 327 273 330 273 L 335 273 Q 340 266 345 273 L 429 273 Q 438 273 438 282 L 438 291" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="2"></path><polygon class="sl-arrow" points="438,291 432.42,282 443.58,282" fill="#42506B"></polygon><rect x="231.07999999999998" y="258" width="94" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="2"></rect><text x="278.08" y="271" 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 320 H 540 V 471 H 438 V 483" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="3"></path><path d="M 522 320 L 531 320 Q 540 320 540 329 L 540 462 Q 540 471 531 471 L 444 471 Q 438 471 438 477 L 438 483" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="3"></path><polygon class="sl-arrow" points="438,483 432.42,474 443.58,474" fill="#42506B"></polygon><rect x="529" y="392.5" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="3"></rect><text x="540" y="405.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 349 V 368 H 234 V 387" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="4"></path><path d="M 438 349 L 438 359 Q 438 368 429 368 L 345 368 Q 340 361 335 368 L 243 368 Q 234 368 234 377 L 234 387" fill="none" stroke="#D32F2F" stroke-width="3" stroke-dasharray="10 6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="4"></path><polygon class="sl-arrow" points="234,387 228.42,378 239.58,378" fill="#D32F2F"></polygon><rect x="354.03999999999996" y="359" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#D32F2F" data-pick="link" data-idx="4"></rect><text x="365.03999999999996" y="372" 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 416 H 340 V 224 H 318" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="5"></path><path d="M 318 416 L 331 416 Q 340 416 340 407 L 340 233 Q 340 224 331 224 L 318 224" fill="none" stroke="#D32F2F" stroke-width="1.6" stroke-dasharray="6 4" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="5"></path><polygon class="sl-arrow" points="318,224 325,219.66 325,228.34" fill="#D32F2F"></polygon><rect x="291" y="311" width="58" height="18" rx="4" fill="#FFFFFF" stroke="#D32F2F" data-pick="link" data-idx="5"></rect><text x="320" y="324" 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 541 V 555 H 531 V 561 H 642 V 579" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="6"></path><path d="M 438 541 L 438 548 Q 438 555 445 555 L 528 555 Q 531 555 531 558 L 531 558 Q 531 561 534 561 L 633 561 Q 642 561 642 570 L 642 579" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="6"></path><polygon class="sl-arrow" points="642,579 636.42,570 647.58,570" fill="#42506B"></polygon><rect x="462.96000000000004" y="546" width="106" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="6"></rect><text x="515.96" y="559" 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 608 H 744 V 759 H 642 V 771" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="7"></path><path d="M 726 608 L 735 608 Q 744 608 744 617 L 744 750 Q 744 759 735 759 L 648 759 Q 642 759 642 765 L 642 771" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="7"></path><polygon class="sl-arrow" points="642,771 636.42,762 647.58,762" fill="#42506B"></polygon><rect x="730" y="680.5" width="28" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="7"></rect><text x="744" y="693.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 637 V 656 H 642 V 675" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="8"></path><path d="M 642 637 L 642 656 Q 642 656 642 656 L 642 656 Q 642 656 642 656 L 642 675" fill="none" stroke="#1565C0" stroke-width="3" stroke-dasharray="10 6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="8"></path><polygon class="sl-arrow" points="642,675 636.42,666 647.58,666" fill="#1565C0"></polygon><rect x="631" y="647" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#1565C0" data-pick="link" data-idx="8"></rect><text x="642" y="660" 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 733 V 752 H 642 V 771" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="9"></path><path d="M 642 733 L 642 752 Q 642 752 642 752 L 642 752 Q 642 752 642 752 L 642 771" fill="none" stroke="#1565C0" stroke-width="1.6" stroke-dasharray="6 4" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="9"></path><polygon class="sl-arrow" points="642,771 637.66,764 646.34,764" fill="#1565C0"></polygon><rect x="607" y="738.44" width="70" height="18" rx="4" fill="#FFFFFF" stroke="#1565C0" data-pick="link" data-idx="9"></rect><text x="642" y="751.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 829 V 843 H 549 V 849 H 438 V 867" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="10"></path><path d="M 642 829 L 642 836 Q 642 843 635 843 L 552 843 Q 549 843 549 846 L 549 846 Q 549 849 546 849 L 447 849 Q 438 849 438 858 L 438 867" 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,867 433.66,860 442.34,860" fill="#42506B"></polygon><rect x="514.04" y="834" width="100" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="10"></rect><text x="564.04" y="847" 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 925 V 936 H 438 V 947" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="11"></path><path d="M 438 925 L 438 936 Q 438 936 438 936 L 438 936 Q 438 936 438 936 L 438 947" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="11"></path><polygon class="sl-arrow" points="438,947 432.42,938 443.58,938" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 438 1005 V 1022 H 438 V 1039" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="12"></path><path d="M 438 1005 L 438 1022 Q 438 1022 438 1022 L 438 1022 Q 438 1022 438 1022 L 438 1039" 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,1039 433.66,1032 442.34,1032" fill="#42506B"></polygon></g><g data-pick="node" data-idx="1"><rect class="sl-shape" x="150" y="115" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="234" y="149" 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,195 318,195 302,253 150,253" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="234" y="229" 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="387" width="168" height="58" rx="7" ry="7" fill="#FFE0E0" stroke="#42506B" stroke-width="1.6"></rect><text x="234" y="421" 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,291 522,320 438,349 354,320" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="438" y="317.5" text-anchor="middle" font-size="12" fill="#16233A">Credit </text><text x="438" y="332.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="483" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="509.5" text-anchor="middle" font-size="12" fill="#16233A">Register the </text><text x="438" y="524.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="867" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="901" 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="947" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="981" 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,579 726,608 642,637 558,608" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="642" y="613" 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="675" width="168" height="58" rx="7" ry="7" fill="#FFF3D6" stroke="#42506B" stroke-width="1.6"></rect><text x="642" y="701.5" text-anchor="middle" font-size="12" fill="#16233A">Order from </text><text x="642" y="716.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="771" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="642" y="805" 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="68" r="13" fill="#42506B" stroke="#42506B" stroke-width="1.6"></circle><rect x="208" y="81" width="52" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect><text x="234" y="94" 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="1052" r="13" fill="#42506B" stroke="#42506B" stroke-width="1.6"></circle><circle cx="438" cy="1052" r="9" fill="#FFFFFF"></circle><circle cx="438" cy="1052" r="6" fill="#42506B"></circle><rect x="421" y="1065" width="34" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect><text x="438" y="1078" 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="1162" viewBox="0 0 790 1162" font-family="Inter, 'Yu Gothic UI', 'Meiryo UI', sans-serif"><rect x="0" y="0" width="790" height="1162" 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="1100" 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="1100" 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="1100" 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><line x1="132" y1="464" x2="744" y2="464" stroke="#D3E1EF" stroke-width="1"></line><line x1="132" y1="848" x2="744" y2="848" stroke="#D3E1EF" stroke-width="1"></line><g data-pick="phase" data-idx="0"><rect class="sl-shape" x="0" y="38" width="132" height="426" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="256" 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="464" width="132" height="384" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="661" 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="848" width="132" height="252" fill="#EEF4FB" stroke="#B9C7DA"></rect><text x="66" y="979" text-anchor="middle" font-size="12" font-weight="700" fill="#3C516C">請求</text></g><g><path class="sl-hit" d="M 234 81 V 98 H 234 V 115" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="0"></path><path d="M 234 81 L 234 98 Q 234 98 234 98 L 234 98 Q 234 98 234 98 L 234 115" 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,115 229.66,108 238.34,108" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 234 173 V 184 H 234 V 195" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="1"></path><path d="M 234 173 L 234 184 Q 234 184 234 184 L 234 184 Q 234 184 234 184 L 234 195" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="1"></path><polygon class="sl-arrow" points="234,195 228.42,186 239.58,186" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 234 253 V 267 H 327 V 273 H 438 V 291" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="2"></path><path d="M 234 253 L 234 260 Q 234 267 241 267 L 324 267 Q 327 267 327 270 L 327 270 Q 327 273 330 273 L 335 273 Q 340 266 345 273 L 429 273 Q 438 273 438 282 L 438 291" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="2"></path><polygon class="sl-arrow" points="438,291 432.42,282 443.58,282" fill="#42506B"></polygon><rect x="260.1" y="258" width="65" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="2"></rect><text x="292.6" y="271" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="2">審査を依頼</text></g><g><path class="sl-hit" d="M 522 320 H 540 V 471 H 438 V 483" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="3"></path><path d="M 522 320 L 531 320 Q 540 320 540 329 L 540 462 Q 540 471 531 471 L 444 471 Q 438 471 438 477 L 438 483" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="3"></path><polygon class="sl-arrow" points="438,483 432.42,474 443.58,474" fill="#42506B"></polygon><rect x="529" y="392.5" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="3"></rect><text x="540" y="405.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 349 V 368 H 234 V 387" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="4"></path><path d="M 438 349 L 438 359 Q 438 368 429 368 L 345 368 Q 340 361 335 368 L 243 368 Q 234 368 234 377 L 234 387" fill="none" stroke="#D32F2F" stroke-width="3" stroke-dasharray="10 6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="4"></path><polygon class="sl-arrow" points="234,387 228.42,378 239.58,378" fill="#D32F2F"></polygon><rect x="354.03999999999996" y="359" width="22" height="18" rx="4" fill="#FFFFFF" stroke="#D32F2F" data-pick="link" data-idx="4"></rect><text x="365.03999999999996" y="372" 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 416 H 340 V 224 H 318" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="5"></path><path d="M 318 416 L 331 416 Q 340 416 340 407 L 340 233 Q 340 224 331 224 L 318 224" fill="none" stroke="#D32F2F" stroke-width="1.6" stroke-dasharray="6 4" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="5"></path><polygon class="sl-arrow" points="318,224 325,219.66 325,228.34" fill="#D32F2F"></polygon><rect x="306.5" y="311" width="43" height="18" rx="4" fill="#FFFFFF" stroke="#D32F2F" data-pick="link" data-idx="5"></rect><text x="328" y="324" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="5">再見積</text></g><g><path class="sl-hit" d="M 438 541 V 555 H 531 V 561 H 642 V 579" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="6"></path><path d="M 438 541 L 438 548 Q 438 555 445 555 L 528 555 Q 531 555 531 558 L 531 558 Q 531 561 534 561 L 633 561 Q 642 561 642 570 L 642 579" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="6"></path><polygon class="sl-arrow" points="642,579 636.42,570 647.58,570" fill="#42506B"></polygon><rect x="483.46000000000004" y="546" width="65" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="6"></rect><text x="515.96" y="559" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="6">出荷を指示</text></g><g><path class="sl-hit" d="M 726 608 H 744 V 759 H 642 V 771" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="7"></path><path d="M 726 608 L 735 608 Q 744 608 744 617 L 744 750 Q 744 759 735 759 L 648 759 Q 642 759 642 765 L 642 771" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="7"></path><polygon class="sl-arrow" points="642,771 636.42,762 647.58,762" fill="#42506B"></polygon><rect x="728" y="648.92" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="7"></rect><text x="744" y="661.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 637 V 656 H 642 V 675" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="8"></path><path d="M 642 637 L 642 656 Q 642 656 642 656 L 642 656 Q 642 656 642 656 L 642 675" fill="none" stroke="#1565C0" stroke-width="3" stroke-dasharray="10 6" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="8"></path><polygon class="sl-arrow" points="642,675 636.42,666 647.58,666" fill="#1565C0"></polygon><rect x="626" y="647" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#1565C0" data-pick="link" data-idx="8"></rect><text x="642" y="660" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="8">なし</text></g><g><path class="sl-hit" d="M 642 733 V 752 H 642 V 771" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="9"></path><path d="M 642 733 L 642 752 Q 642 752 642 752 L 642 752 Q 642 752 642 752 L 642 771" fill="none" stroke="#1565C0" stroke-width="1.6" stroke-dasharray="6 4" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="9"></path><polygon class="sl-arrow" points="642,771 637.66,764 646.34,764" fill="#1565C0"></polygon><rect x="620.5" y="738.44" width="43" height="18" rx="4" fill="#FFFFFF" stroke="#1565C0" data-pick="link" data-idx="9"></rect><text x="642" y="751.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 829 V 843 H 549 V 849 H 438 V 867" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="10"></path><path d="M 642 829 L 642 836 Q 642 843 635 843 L 552 843 Q 549 843 549 846 L 549 846 Q 549 849 546 849 L 447 849 Q 438 849 438 858 L 438 867" 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,867 433.66,860 442.34,860" fill="#42506B"></polygon><rect x="531.54" y="834" width="65" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="10"></rect><text x="564.04" y="847" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="10">出荷を通知</text></g><g><path class="sl-hit" d="M 438 925 V 936 H 438 V 947" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="11"></path><path d="M 438 925 L 438 936 Q 438 936 438 936 L 438 936 Q 438 936 438 936 L 438 947" fill="none" stroke="#42506B" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="11"></path><polygon class="sl-arrow" points="438,947 432.42,938 443.58,938" fill="#42506B"></polygon></g><g><path class="sl-hit" d="M 438 1005 V 1022 H 438 V 1039" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="12"></path><path d="M 438 1005 L 438 1022 Q 438 1022 438 1022 L 438 1022 Q 438 1022 438 1022 L 438 1039" 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,1039 433.66,1032 442.34,1032" fill="#42506B"></polygon></g><g data-pick="node" data-idx="1"><rect class="sl-shape" x="150" y="115" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="234" y="149" text-anchor="middle" font-size="12" fill="#16233A">見積を出す</text></g><g data-pick="node" data-idx="2"><polygon class="sl-shape" points="166,195 318,195 302,253 150,253" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="234" y="229" text-anchor="middle" font-size="12" fill="#16233A">注文を受ける</text></g><g data-pick="node" data-idx="4"><rect class="sl-shape" x="150" y="387" width="168" height="58" rx="7" ry="7" fill="#FFE0E0" stroke="#42506B" stroke-width="1.6"></rect><text x="234" y="421" text-anchor="middle" font-size="12" fill="#16233A">条件を見直す</text></g><g data-pick="node" data-idx="3"><polygon class="sl-shape" points="438,291 522,320 438,349 354,320" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="438" y="317.5" text-anchor="middle" font-size="12" fill="#16233A">与信は足りる</text><text x="438" y="332.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="483" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="517" text-anchor="middle" font-size="12" fill="#16233A">受注を登録する</text></g><g data-pick="node" data-idx="9"><rect class="sl-shape" x="354" y="867" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="901" text-anchor="middle" font-size="12" fill="#16233A">請求書を送る</text></g><g data-pick="node" data-idx="10"><rect class="sl-shape" x="354" y="947" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="438" y="981" text-anchor="middle" font-size="12" fill="#16233A">入金を確認する</text></g><g data-pick="node" data-idx="6"><polygon class="sl-shape" points="642,579 726,608 642,637 558,608" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></polygon><text x="642" y="613" text-anchor="middle" font-size="12" fill="#16233A">在庫はあるか</text></g><g data-pick="node" data-idx="7"><rect class="sl-shape" x="558" y="675" width="168" height="58" rx="7" ry="7" fill="#FFF3D6" stroke="#42506B" stroke-width="1.6"></rect><text x="642" y="709" text-anchor="middle" font-size="12" fill="#16233A">取り寄せる</text></g><g data-pick="node" data-idx="8"><rect class="sl-shape" x="558" y="771" width="168" height="58" rx="7" ry="7" fill="#FFFFFF" stroke="#42506B" stroke-width="1.6"></rect><text x="642" y="805" text-anchor="middle" font-size="12" fill="#16233A">出荷する</text></g><g data-pick="node" data-idx="0"><circle class="sl-shape" cx="234" cy="68" r="13" fill="#42506B" stroke="#42506B" stroke-width="1.6"></circle><rect x="218" y="81" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect><text x="234" y="94" text-anchor="middle" font-size="11" fill="#3C516C">引合</text></g><g data-pick="node" data-idx="11"><circle class="sl-shape" cx="438" cy="1052" r="13" fill="#42506B" stroke="#42506B" stroke-width="1.6"></circle><circle cx="438" cy="1052" r="9" fill="#FFFFFF"></circle><circle cx="438" cy="1052" r="6" fill="#42506B"></circle><rect x="422" y="1065" width="32" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect><text x="438" y="1078" 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.4.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,12 +25,14 @@
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",
33
- "test": "node test/meta.test.js && node test/port-rule.test.js && node test/header-fit.test.js && node test/readability.test.js"
35
+ "test": "node test/meta.test.js && node test/port-rule.test.js && node test/header-fit.test.js && node test/readability.test.js && node test/roundtrip.test.js && node test/phase-band.test.js"
34
36
  },
35
37
  "engines": {
36
38
  "node": ">=14"
package/swimlane.js CHANGED
@@ -68,10 +68,29 @@ const DOT_SIZE = 26;
68
68
  const DOT_GAP = 34;
69
69
  const DOT_SLOT = DOT_SIZE + DOT_GAP;
70
70
  const isDot = (shape)=> DOT_SHAPES.includes(shape);
71
+ /* 線種と、それを書くための記法。線が1本なら実線、2本なら破線。`=` にすると太くなる。
72
+ Mermaid のフローチャートでは `-->` が実線・`==>` が太い実線だが、こちらは
73
+ swimlane 記法の中での規則性を採るので、どちらも逆の意味になる。
74
+ SGS は線種セレクトと接続一覧をこの一覧から作るので、記法も一緒に持たせる。 */
71
75
  const LINK_STYLES = [
72
- { v:'solid', label:'実線' },
73
- { v:'dashed', label:'破線' },
76
+ { v:'solid', label:'実線', arrow:'->' },
77
+ { v:'dashed', label:'破線', arrow:'-->' },
78
+ { v:'thick', label:'太い実線', arrow:'=>' },
79
+ { v:'thickDashed', label:'太い破線', arrow:'==>' },
74
80
  ];
81
+ const LINK_DEFAULT_STYLE = LINK_STYLES[0];
82
+ /* 接続行を読む正規表現と、連鎖を見つけるための正規表現。長い記法から試す必要がある。
83
+ 上の LINK_STYLES と食い違わないことは test/roundtrip.test.js で見ている */
84
+ const LINK_ARROW_RE = /(==>|=>|-->|->)/;
85
+ const arrowOfStyle = (style)=> (LINK_STYLES.find(s=>s.v === style) || LINK_DEFAULT_STYLE).arrow;
86
+ const styleOfArrow = (arrow)=> (LINK_STYLES.find(s=>s.arrow === arrow) || LINK_DEFAULT_STYLE).v;
87
+ const isThickLink = (style)=> style === 'thick' || style === 'thickDashed';
88
+ const isDashedLink = (style)=> style === 'dashed' || style === 'thickDashed';
89
+ /* 線の既定色。color を指定しなかったときはこれで描く */
90
+ const LINK_COLOR = '#42506B';
91
+ /* レーンの上に引くフェーズの境目の色。帯の枠(#B9C7DA)より薄くして、
92
+ 図形や線より手前に出てこないようにする */
93
+ const PHASE_RULE = '#D3E1EF';
75
94
  function esc(s){
76
95
  return String(s == null ? '' : s)
77
96
  .replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;')
@@ -82,9 +101,18 @@ function quote(s){
82
101
  }
83
102
  /* 接続ラベルのおおよその表示幅(px)。ラベル背景の白丸角パネルの実際の幅と合わせて使う。
84
103
  全角文字は半角の約2倍として概算する(等幅ではないので目安値)。 */
104
+ /* 接続ラベルの白い箱の高さ。描画と間隔の計算で同じ値を使う */
105
+ const LABEL_BOX_H = 18;
85
106
  function labelPixelWidth(label){
86
107
  return [...String(label || '')].reduce((n, ch) => n + (/[\x00-\xff]/.test(ch) ? 6 : 11), 0) + 10;
87
108
  }
109
+ /* 接続ラベルが「流れの向き」に要する大きさ(px)。
110
+ LR では文字の長さがそのまま効くが、TB では箱の高さ(18px)しか要らない。
111
+ ここを取り違えると、長いラベルが1つあるだけでフェーズ全体の段が間延びする。 */
112
+ function labelMainExtent(label, dir){
113
+ return dir === 'LR' ? labelPixelWidth(label) + 16 : LABEL_BOX_H + 20;
114
+ }
115
+
88
116
  /* 見出し(レーン名・フェーズ名)のおおよその表示幅(px)。
89
117
  太字なので、全角はフォントサイズとほぼ同じ幅、半角はその約6割として概算する。 */
90
118
  function headerTextWidth(label, fontSize){
@@ -122,8 +150,11 @@ function generateCode(state){
122
150
  if(state.links.length){
123
151
  lines.push('');
124
152
  state.links.forEach(e=>{
125
- const arrow = e.style === 'dashed' ? '-->' : '->';
126
- lines.push(`${e.from} ${arrow} ${e.to}${e.label ? ' ' + quote(e.label) : ''}`);
153
+ const attrs = [];
154
+ if(e.color) attrs.push('color=' + e.color);
155
+ lines.push(`${e.from} ${arrowOfStyle(e.style)} ${e.to}`
156
+ + (e.label ? ' ' + quote(e.label) : '')
157
+ + (attrs.length ? ' ' + attrs.join(' ') : ''));
127
158
  });
128
159
  }
129
160
  if(!state.lanes.length && !state.nodes.length){
@@ -196,13 +227,27 @@ function parseCode(text){
196
227
  });
197
228
  return;
198
229
  }
199
- // 接続: A -> B "ラベル" / A --> B
200
- const link = line.match(/^(\S+)\s*(-->|->)\s*(\S+)(.*)$/);
230
+ // 接続: A -> B "ラベル" / A --> B / A => B / A ==> B / A -> B color=#D32F2F
231
+ // 1つめを控えめ(\S+?)にする。欲張りだと `A-->B` の from が `A-` になり、
232
+ // 線種も破線ではなく実線になっていた(空白を入れた `A --> B` だけが正しく読めていた)。
233
+ const link = line.match(/^(\S+?)\s*(==>|=>|-->|->)\s*(\S+)(.*)$/);
201
234
  if(link){
235
+ const tail = takeLabel(link[4] || '');
236
+ // `A -> B -> C` は from=A, to=B になり残りが黙って捨てられていた。はっきり断る
237
+ if(LINK_ARROW_RE.test(tail.rest)){
238
+ errors.push(`${lineNo}行目: 1行でつなげるのは2つまでです → ${line}`);
239
+ return;
240
+ }
241
+ const attr = {};
242
+ tail.rest.split(/\s+/).filter(Boolean).forEach(t=>{
243
+ const eq = t.indexOf('=');
244
+ if(eq > 0) attr[t.slice(0, eq)] = t.slice(eq + 1);
245
+ });
202
246
  next.links.push({
203
247
  from: link[1], to: link[3],
204
- label: takeLabel(link[4] || '').label,
205
- style: link[2] === '-->' ? 'dashed' : 'solid',
248
+ label: tail.label,
249
+ style: styleOfArrow(link[2]),
250
+ color: attr.color || '',
206
251
  });
207
252
  return;
208
253
  }
@@ -228,6 +273,7 @@ const LAYOUT = {
228
273
  phaseHeaderH: 38, // フェーズ名の帯
229
274
  nodeW: 168, nodeH: 58,
230
275
  gapMain: 34, // フェーズとフェーズの間隔
276
+ phasePad: 17, // フェーズ帯の内側の余白(隣の帯と gapMain を分け合った分と同じ値)
231
277
  gapInner: 22, // 同じフェーズ内で流れ方向に並べるときの間隔
232
278
  gapCross: 18, // レーンを横切る向き(分岐で枝を並べたとき)の間隔
233
279
  };
@@ -643,7 +689,7 @@ function computeLayout(state){
643
689
  const laneRuns = lanes.map(l=> Math.max(1, laneCross.get(l.id) || 0));
644
690
 
645
691
  const headerMain = dir === 'LR' ? L.laneHeaderW : L.phaseHeaderH;
646
- const mainStart = headerMain + leadPad; // 先頭に開始●があれば、その分だけ流れ方向にずらす
692
+ const mainStart = headerMain + leadPad + L.phasePad; // 先頭に開始●があれば、その分だけ流れ方向にずらす。帯の内側の余白も空ける
647
693
  const crossStart = dir === 'LR'
648
694
  ? (hasPhaseHeader ? L.phaseHeaderH : 0)
649
695
  : (hasPhaseHeader ? L.laneHeaderW : 0);
@@ -683,30 +729,45 @@ function computeLayout(state){
683
729
  const ap = state.phases.length ? (A.phaseId || phases[0].id) : '__all';
684
730
  const bp = state.phases.length ? (B.phaseId || phases[0].id) : '__all';
685
731
  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);
732
+ if((aj === j && bj === j + 1) || (aj === j + 1 && bj === j)) need = Math.max(need, labelMainExtent(e.label, dir));
687
733
  });
688
734
  if(need) gapAfter[j] = Math.max(gapAfter[j], need);
689
735
  }
690
736
 
691
- // フェーズ内にラベル付きの接続があると、流れ方向の間隔を広げてラベルの前後に棒を出す(要求1.2)。
692
- // こちらも同様に、ラベルの実際の表示幅から必要な間隔を求める(要求1.2)。
693
- const phaseGap = phases.map(p=>{
694
- let need = L.gapInner;
737
+ /* 段と段の隙間は、その隙間を実際に何が通るかで決める(フェーズ内で一律にしない)。
738
+ ラベル付きの接続がまたぐ隙間だけを広げ、何も通らない隙間は gapInner のまま詰める。
739
+ 一律にしていた頃は、長いラベルが1つあるだけでフェーズ全体が間延びしていた
740
+ (英語版の Intake が 110px、ラベルの無い Billing が 22px で、同じ図の中で揃わなかった)。 */
741
+ const phaseGapAt = phases.map((p, j)=>{
742
+ const gaps = new Array(Math.max(0, phaseRuns[j] - 1)).fill(L.gapInner);
743
+ if(!gaps.length) return gaps;
695
744
  state.links.forEach(e=>{
696
745
  if(!e.label) return;
697
746
  const A = state.nodes.find(n=> n.id === e.from), B = state.nodes.find(n=> n.id === e.to);
698
747
  if(!A || !B) return;
699
748
  const ap = state.phases.length ? (A.phaseId || phases[0].id) : '__all';
700
749
  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);
750
+ if(ap !== p.id || bp !== p.id) return;
751
+ const pa = nodePos.get(A.id), pb = nodePos.get(B.id);
752
+ if(!pa || !pb) return;
753
+ const lo = Math.min(pa.flow, pb.flow), hi = Math.max(pa.flow, pb.flow);
754
+ const need = labelMainExtent(e.label, dir);
755
+ // 同じ段どうし(lo === hi)はレーンの間を横に走るので、段の隙間には関係しない
756
+ for(let r = lo; r < hi && r < gaps.length; r++) gaps[r] = Math.max(gaps[r], need);
702
757
  });
703
- return need;
758
+ return gaps;
759
+ });
760
+ // フェーズの先頭から各段までの距離。隙間が段ごとに違うので足し上げて持つ
761
+ const phaseOffsets = phases.map((p, j)=>{
762
+ const offs = [0];
763
+ for(let r = 1; r < phaseRuns[j]; r++) offs.push(offs[r - 1] + nodeMain + phaseGapAt[j][r - 1]);
764
+ return offs;
704
765
  });
705
766
 
706
767
  const phaseBands = [];
707
768
  let main = mainStart;
708
769
  phases.forEach((p, j)=>{
709
- let size = phaseRuns[j] * nodeMain + (phaseRuns[j] - 1) * phaseGap[j];
770
+ let size = phaseOffsets[j][phaseRuns[j] - 1] + nodeMain;
710
771
  // LRではフェーズ名が上の細い帯(高さ38px固定)に横書きで入る。縦には広げられないので、
711
772
  // 名前が帯より長いときは帯の長さ(流れ方向)を広げる。広げないとはみ出して切れる。
712
773
  if(hasPhaseHeader && dir === 'LR') size = Math.max(size, headerTextWidth(p.label, 12) + 16);
@@ -735,7 +796,7 @@ function computeLayout(state){
735
796
  const list = cell.get(key(l.id, p.id)) || [];
736
797
  list.forEach((n)=>{
737
798
  const { flow: col, cross: row } = nodePos.get(n.id);
738
- const mainPos = phaseBands[j].start + col * (nodeMain + phaseGap[j]);
799
+ const mainPos = phaseBands[j].start + (phaseOffsets[j][col] != null ? phaseOffsets[j][col] : col * (nodeMain + L.gapInner));
739
800
  const crossPos = band.start + L.gapCross + row * (nodeCross + L.gapCross);
740
801
  const slot = dir === 'LR'
741
802
  ? { x: mainPos, y: crossPos, w: L.nodeW, h: L.nodeH }
@@ -844,33 +905,50 @@ function computeLayout(state){
844
905
  const pid = isDot(b.node.shape) ? dotPhase.get(b.node) : phaseIdOf(b.node);
845
906
  const j = phases.findIndex(p=> p.id === pid);
846
907
  if(j < 0) return;
847
- const s = dir === 'LR' ? b.x : b.y, e = dir === 'LR' ? b.x + b.w : b.y + b.h;
908
+ let s = dir === 'LR' ? b.x : b.y, e = dir === 'LR' ? b.x + b.w : b.y + b.h;
909
+ /* ●のラベルは●の枠の外(真下)に白い箱で添えるので、箱の分まで帯に入れる。
910
+ 入れないと最後の●の「完了」が帯の縁の線に触る。寸法は描画側と同じものを使う。 */
911
+ if(isDot(b.node.shape) && b.node.label){
912
+ if(dir === 'LR'){
913
+ const half = labelPixelWidth(b.node.label) / 2, cx = b.x + b.w / 2;
914
+ s = Math.min(s, cx - half); e = Math.max(e, cx + half);
915
+ }else{
916
+ e = Math.max(e, b.y + b.h + LABEL_BOX_H);
917
+ }
918
+ }
848
919
  lo[j] = Math.min(lo[j], s); hi[j] = Math.max(hi[j], e);
849
920
  });
850
- // 前の帯の終端を覚えておき、重ならないように順に確定する。
851
- // ノードが無いフェーズは既定の幅(phaseRuns基準のサイズ)を保ったまま、位置だけ前の帯に合わせる。
921
+ // 中身の無いフェーズは、既定の大きさを保ったまま前のフェーズの後ろに置く
922
+ let tail = null;
923
+ phases.forEach((p, j)=>{
924
+ if(lo[j] !== Infinity){ tail = hi[j]; return; }
925
+ const s = tail != null ? tail + L.gapMain : mainStart;
926
+ lo[j] = s;
927
+ hi[j] = s + Math.max(0, phaseBands[j].size - L.phasePad * 2);
928
+ tail = hi[j];
929
+ });
930
+ /* 帯の縁を決める。隣り合う帯はノードどうしの隙間を真ん中で分け合い、地続きに並べる。
931
+ 離して並べていた頃は帯の縁が26px空いて2本並び、レーンの上にフェーズの境界線を
932
+ 引いてもどちらが境目なのか分からなかった。内側の余白 phasePad は、
933
+ 隙間を分け合った分(gapMain の半分)と同じ値にしてあるので、どの帯も同じだけ空く。 */
852
934
  let prevEnd = null;
853
935
  phases.forEach((p, j)=>{
854
- if(lo[j] === Infinity){
855
- const s = prevEnd != null ? prevEnd + L.gapMain / 2 : phaseBands[j].start;
856
- phaseBands[j].start = s; // size は既定値のまま変更しない
857
- prevEnd = s + phaseBands[j].size;
858
- return;
859
- }
860
- let s = lo[j] - 6, e = hi[j] + 6;
861
- if(prevEnd != null) s = Math.max(s, (prevEnd + lo[j]) / 2); // 直前とは中間で分ける
862
- if(j === 0) s = Math.max(headerMain, s);
936
+ const s = j === 0
937
+ ? Math.max(headerMain, lo[0] - L.phasePad) // 先頭はレーン名の帯にくっつける
938
+ : Math.max((hi[j - 1] + lo[j]) / 2, prevEnd); // 以降は前の帯の終端から続ける
939
+ let e = j === phases.length - 1 ? hi[j] + L.phasePad : (hi[j] + lo[j + 1]) / 2;
863
940
  // LRではフェーズ名が上の細い帯(高さ38px固定)に横書きで入る。ノードの位置ぴったりに
864
941
  // 詰めると名前がはみ出して切れるので、名前に要る長さは残す。
865
- // 帯どうしの間隔は上で名前のぶんを見込んで取ってあるので、ここで広げても隣とぶつからない。
942
+ // 帯の間隔は上で名前のぶんを見込んで取ってあるので、ここで広げても隣とぶつからない。
866
943
  if(hasPhaseHeader && dir === 'LR') e = Math.max(e, s + headerTextWidth(p.label, 12) + 16);
867
944
  phaseBands[j].start = s;
868
945
  phaseBands[j].size = Math.max(0, e - s);
869
- prevEnd = e;
946
+ prevEnd = s + phaseBands[j].size;
870
947
  });
871
- // 帯の拡張で末尾が伸びていれば、全体サイズもそれに合わせる(描画が切れないように)
872
- const lastBand = phaseBands[phases.length - 1];
873
- mainTotal = Math.max(mainTotal, lastBand.start + lastBand.size + trailPad + L.gapMain / 2);
948
+ /* 図の長さは最後の帯の終端で決める。以前はここに trailPad(終了●の分)と gapMain/2 を
949
+ 足していたが、終了●はもう帯の中に入っているので二重に空けていた
950
+ (examples/order.swim で最後のフェーズの下に 77px の空白が出ていた)。 */
951
+ mainTotal = phaseBands[phases.length - 1].start + phaseBands[phases.length - 1].size;
874
952
  }
875
953
 
876
954
  const width = dir === 'LR' ? mainTotal : crossTotal;
@@ -1167,8 +1245,8 @@ function crossingsAndJunctions(renders){
1167
1245
  return { hopsBy };
1168
1246
  }
1169
1247
 
1170
- function arrowHead(tip){
1171
- const s = 7;
1248
+ function arrowHead(tip, color, thick){
1249
+ const s = thick ? 9 : 7;
1172
1250
  const { x, y, dirn } = tip;
1173
1251
  const pts = {
1174
1252
  right: `${x},${y} ${x-s},${y-s*0.62} ${x-s},${y+s*0.62}`,
@@ -1176,7 +1254,7 @@ function arrowHead(tip){
1176
1254
  down: `${x},${y} ${x-s*0.62},${y-s} ${x+s*0.62},${y-s}`,
1177
1255
  up: `${x},${y} ${x-s*0.62},${y+s} ${x+s*0.62},${y+s}`,
1178
1256
  }[dirn];
1179
- return `<polygon class="sl-arrow" points="${pts}" fill="#42506B"></polygon>`;
1257
+ return `<polygon class="sl-arrow" points="${pts}" fill="${esc(color || LINK_COLOR)}"></polygon>`;
1180
1258
  }
1181
1259
 
1182
1260
  /* ---- エッジ経路の補助(分岐の角出し・ノード回避) ---- */
@@ -1582,6 +1660,7 @@ function drawSvg(state){
1582
1660
  const segsOf = new Map();
1583
1661
  linkRenders.forEach(item=>{ if(item) segsOf.set(item.i, pathSegmentsOf(item.p.d)); });
1584
1662
  const placedBoxes = [];
1663
+ const nodeBoxes = lay.boxes.map(b=> ({ x:b.x, y:b.y, w:b.w, h:b.h }));
1585
1664
  linkRenders.forEach(item=>{
1586
1665
  if(!item || !item.e.label) return;
1587
1666
  const others = [];
@@ -1589,16 +1668,38 @@ function drawSvg(state){
1589
1668
  const clear = (mid)=>{
1590
1669
  const box = labelBoxOf(mid, item.e.label);
1591
1670
  if(others.some(([x1, y1, x2, y2])=> segHitsBox(x1, y1, x2, y2, box))) return false;
1671
+ // ノードの箱に重なると、図形の文字とラベルが混ざって読めなくなる
1672
+ if(nodeBoxes.some(b=> overlaps(box, b))) return false;
1592
1673
  return !placedBoxes.some(b=> overlaps(box, b));
1593
1674
  };
1594
1675
  let mid = item.p.mid;
1595
1676
  if(mid && !clear(mid)){
1596
- // 真ん中から外側へ、少しずつ離れた位置を試す。最初に空いた所へ置く。
1597
1677
  const own = segsOf.get(item.i) || [];
1598
- for(const t of [0.38, 0.62, 0.28, 0.72, 0.2, 0.8]){
1678
+ // 1) まず経路に沿って前後へずらす。線の上に載ったままなので、見た目がいちばん素直
1679
+ let found = null;
1680
+ 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
1681
  const cand = pointAt(own, t);
1600
- if(cand && clear(cand)){ mid = cand; break; }
1682
+ if(cand && clear(cand)){ found = cand; break; }
1683
+ }
1684
+ // 2) それでも空かないときは、経路から横へ少しだけ外す。
1685
+ // 戻りの辺のように、ノードのすぐ脇を通る線はどこへずらしても箱に重なるため
1686
+ // (英語版の「Re-quote」が「Revise the terms」に7px重なっていた)。
1687
+ if(!found){
1688
+ for(const off of [12, -12, 20, -20, 30, -30, 42, -42]){
1689
+ for(const seg of own){
1690
+ const [x1, y1, x2, y2] = seg;
1691
+ const horiz = Math.abs(y1 - y2) < 0.5;
1692
+ for(const u of [0.5, 0.35, 0.65, 0.25, 0.75]){
1693
+ const px = x1 + (x2 - x1) * u, py = y1 + (y2 - y1) * u;
1694
+ const cand = horiz ? { x:px, y:py + off } : { x:px + off, y:py };
1695
+ if(clear(cand)){ found = cand; break; }
1696
+ }
1697
+ if(found) break;
1698
+ }
1699
+ if(found) break;
1700
+ }
1601
1701
  }
1702
+ if(found) mid = found;
1602
1703
  }
1603
1704
  if(mid){
1604
1705
  item.p.mid = mid;
@@ -1657,6 +1758,17 @@ function drawSvg(state){
1657
1758
  }
1658
1759
  });
1659
1760
 
1761
+ /* フェーズの境目を、レーンの上にも薄く引く。
1762
+ フェーズ名は端の列にしか出ないので、名前が無い側ではノードがどのフェーズに
1763
+ 入っているのかを目で辿ることになっていた。帯は地続きなので境目は1本で足りる。 */
1764
+ if(lay.hasPhaseHeader && lay.phaseBands.length > 1){
1765
+ lay.phaseBands.slice(1).forEach(pb=>{
1766
+ out.push(lay.dir === 'LR'
1767
+ ? `<line x1="${pb.start}" y1="${LAYOUT.phaseHeaderH}" x2="${pb.start}" y2="${lay.height}" stroke="${PHASE_RULE}" stroke-width="1"></line>`
1768
+ : `<line x1="${LAYOUT.laneHeaderW}" y1="${pb.start}" x2="${lay.width}" y2="${pb.start}" stroke="${PHASE_RULE}" stroke-width="1"></line>`);
1769
+ });
1770
+ }
1771
+
1660
1772
  // フェーズの見出し
1661
1773
  if(lay.hasPhaseHeader){
1662
1774
  lay.phaseBands.forEach(pb=>{
@@ -1683,16 +1795,21 @@ function drawSvg(state){
1683
1795
  linkRenders.forEach(item=>{
1684
1796
  if(!item) return;
1685
1797
  const { e, i, p } = item;
1686
- const dash = e.style === 'dashed' ? ' stroke-dasharray="6 4"' : '';
1798
+ // 太線で `6 4` のままだと刻みが詰まって実線に見えるので、太いときは広げる
1799
+ const thick = isThickLink(e.style);
1800
+ const stroke = e.color || LINK_COLOR;
1801
+ const dash = isDashedLink(e.style)
1802
+ ? (thick ? ' stroke-dasharray="10 6"' : ' stroke-dasharray="6 4"')
1803
+ : '';
1687
1804
  // 見た目だけ角丸+またぎにする。当たり判定(class="sl-hit")は直角のままでよい
1688
1805
  const shown = decoratePath(pathSegmentsOf(p.d), hopsBy.get(i) || []) || p.d;
1689
1806
  out.push(`<g>`);
1690
1807
  out.push(`<path class="sl-hit" d="${p.d}" fill="none" stroke="transparent" stroke-width="14" data-pick="link" data-idx="${i}"></path>`);
1691
- out.push(`<path d="${shown}" fill="none" stroke="#42506B" stroke-width="1.6"${dash} stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="${i}"></path>`);
1692
- out.push(arrowHead(p.tip));
1808
+ out.push(`<path d="${shown}" fill="none" stroke="${esc(stroke)}" stroke-width="${thick ? 3 : 1.6}"${dash} stroke-linecap="round" stroke-linejoin="round" data-pick="link" data-idx="${i}"></path>`);
1809
+ out.push(arrowHead(p.tip, stroke, thick));
1693
1810
  if(e.label){
1694
1811
  const tw = labelPixelWidth(e.label);
1695
- out.push(`<rect x="${p.mid.x - tw/2}" y="${p.mid.y - 9}" width="${tw}" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF" data-pick="link" data-idx="${i}"></rect>`);
1812
+ out.push(`<rect x="${p.mid.x - tw/2}" y="${p.mid.y - 9}" width="${tw}" height="18" rx="4" fill="#FFFFFF" stroke="${esc(e.color || '#D3E1EF')}" data-pick="link" data-idx="${i}"></rect>`);
1696
1813
  out.push(`<text x="${p.mid.x}" y="${p.mid.y + 4}" text-anchor="middle" font-size="11" fill="#3C516C" data-pick="link" data-idx="${i}">${esc(e.label)}</text>`);
1697
1814
  }
1698
1815
  out.push(`</g>`);
@@ -1711,7 +1828,7 @@ function drawSvg(state){
1711
1828
  if(n.label){
1712
1829
  const tw = labelPixelWidth(n.label);
1713
1830
  const cx = b.x + b.w / 2, base = b.y + b.h + 13;
1714
- out.push(`<rect x="${cx - tw/2}" y="${base - 13}" width="${tw}" height="18" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect>`);
1831
+ out.push(`<rect x="${cx - tw/2}" y="${base - 13}" width="${tw}" height="${LABEL_BOX_H}" rx="4" fill="#FFFFFF" stroke="#D3E1EF"></rect>`);
1715
1832
  out.push(`<text x="${cx}" y="${base}" text-anchor="middle" font-size="11" fill="#3C516C">${esc(n.label)}</text>`);
1716
1833
  }
1717
1834
  }else{
@@ -1754,9 +1871,10 @@ function renderTo(target, code){
1754
1871
  }
1755
1872
 
1756
1873
  return {
1757
- VERSION: '1.2.1',
1874
+ VERSION: '1.4.0',
1758
1875
  SHAPES,
1759
1876
  LINK_STYLES,
1877
+ LINK_COLOR,
1760
1878
  isDot,
1761
1879
  parse: parseCode,
1762
1880
  generate: generateCode,