-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathlibrary.htm
904 lines (715 loc) · 22.1 KB
/
library.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="content-security-policy" content="
base-uri 'self';
default-src 'none';
script-src 'self';
style-src 'self' 'sha256-s7UPtBgvov5WNF9C1DlTZDpqwLgEmfiWha5a5p/Zn7E=';
font-src 'self' data:;
img-src 'self';
form-action 'none';
">
<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0">
<title>Sequence Diagram Library</title>
<link rel="icon" href="web/resources/favicon.png">
<link rel="apple-touch-icon" href="web/resources/apple-touch-icon.png">
<link rel="stylesheet" href="web/styles/library.css">
<link rel="stylesheet" href="web/lib/codemirror.css">
<link rel="stylesheet" href="web/styles/codemirror-override.css">
<script src="web/lib/docs.js" type="module"></script>
</head>
<body>
<article>
<header>
<h1>Sequence Diagram</h1>
<pre class="sequence-diagram">
define Complex System as sys
define User as usr
define Sequence Diagram as diagram
define Other Users as usr2
begin sys, usr, usr2
sys ~> usr
note over usr: "Take time to\nunderstand System"
usr -> *diagram: Create
usr -> usr2: Inform
usr2 <-> diagram: Learn & understand
usr2 -> sys: Use
terminators box
</pre>
</header>
<h2 id="Introduction">Introduction</h2>
<p>
Want to draw a Sequence Diagram?
<a href="." target="_blank" rel="noopener">Go to the online editor</a>.
</p>
<p>
This library renders sequence diagrams from code. It is
<a href="https://github.com/davidje13/SequenceDiagram" target="_blank" rel="noopener">open-source</a>
(LGPL-3.0), and including it in a website is as simple as adding the script:</p>
<pre data-lang="text/html">
<script src="lib/sequence-diagram-web.js"></script>
</pre>
<p>If you are using NPM to manage dependencies, you can install with:</p>
<pre data-lang="shell">
npm install --save svg-sequence-diagram
</pre>
<p>And import with:</p>
<pre data-lang="javascript">
import 'svg-sequence-diagram';
</pre>
<p>Or:</p>
<pre data-lang="javascript">
require('svg-sequence-diagram');
</pre>
<p>
Any element with the class <code>sequence-diagram</code> will automatically be
converted when the page loads:
</p>
<div class="right">
<pre class="sequence-diagram" data-lang="sequence">
A -> B: foo
B -> A: bar
</pre>
</div>
<pre data-lang="text/html" class="print-reduced">
<pre class="sequence-diagram">
A -> B: foo
B -> A: bar
</pre>
</pre>
<h2 id="Language">Language</h2>
<section>
<h3 id="ConnectionTypes">Connection Types</h3>
<pre class="example" data-lang="sequence">
title Connection Types
begin Foo, Bar, Baz
Foo -> Bar: Simple arrow
Bar --> Baz: Dashed arrow
Foo <- Bar: Reversed arrow
Bar <-- Baz: Reversed & dashed
Foo <-> Bar: Double arrow
Bar <--> Baz: Double dashed arrow
# An arrow with no label:
Foo -> Bar
Bar ->> Baz: Different arrow
Foo <<--> Bar: Mix of arrows
Bar -> Bar: Bar talks to itself
Foo -> +Bar: Foo asks Bar
-Bar --> Foo: and Bar replies
Bar -x Baz: Lost message
# Arrows leaving on the left and right of the diagram
[ -> Foo: From the left
[ <- Foo: To the left
Foo -> ]: To the right
Foo <- ]: From the right
[ ~> ]: Wavy left to right!
# (etc.)
</pre>
</section>
<section>
<h3 id="Dividers">Dividers</h3>
<pre class="example" data-lang="sequence">
title Dividers
begin Foo, Bar, Baz
Foo -> +Bar
divider
Bar -> +Baz
divider delay: This takes a while
-Baz --> Bar
divider tear with height 20: Lots of stuff happens
-Bar --> Foo
</pre>
</section>
<section>
<h3 id="NotesState">Notes & State</h3>
<pre class="example" data-lang="sequence">
title Note Placements
begin Foo, Bar
note over Foo: Foo says something
note left of Foo: Stuff
note right of Bar: More stuff
note over Foo, Bar: "Foo and Bar
on multiple lines"
note between Foo, Bar: Link
# in long diagrams, we can add reminders of which agent is which:
relabel
text right: "Comments\nOver here!"
state over Foo: Foo is ponderous
</pre>
</section>
<section>
<h3 id="Logic">Logic</h3>
<pre class="example" data-lang="sequence">
title At the Bank
begin Person, ATM, Bank
Person -> ATM: Request money
ATM -> Bank: Check funds
if fraud detected
Bank -> Police: "Get 'em!"
Police -> Person: "You're nicked"
end Police
else if sufficient funds
ATM -> Bank: Withdraw funds
repeat until "all requested money
has been handed over"
ATM -> Person: Dispense note
end
else
ATM -> Person: Error
end
</pre>
</section>
<section>
<h3 id="LabelTemplates">Label Templates</h3>
<pre class="example" data-lang="sequence">
autolabel "[<inc>] <label>"
begin "Underpants\nGnomes" as A
A <- ]: Collect underpants
A <-> ]: ???
A <- ]: Profit!
</pre>
</section>
<section>
<h3 id="MultilineText">Multiline Text</h3>
<pre class="example" data-lang="sequence">
title "My Multiline
Title"
begin Foo, Bar
note over Foo: "Also possible\nwith escapes"
Foo -> Bar: "Lines of text\non this arrow"
if "Even multiline\ninside conditions like this"
Foo -> "Multiline\nagent"
end
state over Foo: "Newlines here,
too!"
</pre>
</section>
<section>
<h3 id="Themes">Themes</h3>
<pre class="example" data-lang="sequence">
theme sketch
title Mockup
A thing -> +Another thing: Something happens
-Another thing --> A thing: With some response
note right of Another thing: Find out what happens here
end Another thing
</pre>
<h4>Available themes</h4>
<ul>
<li>basic</li>
<li>monospace</li>
<li>chunky</li>
<li>sketch</li>
<li>sketch left handed</li>
</ul>
</section>
<section>
<h3 id="ShortLivedAgents">Short-Lived Agents</h3>
<pre class="example" data-lang="sequence">
title "Baz doesn't live long"
note over Foo, Bar: Using begin / end
begin Baz
Bar -> Baz
Baz -> Foo
end Baz
note over Foo, Bar: Using * / !
# * and ! cause agents to be
# created and destroyed inline
Bar -> *Baz: make Baz
Foo <- !Baz: end Baz
# Foo and Bar end with black bars
terminators bar
# (options are: box, bar, cross, fade, none)
</pre>
</section>
<section>
<h3 id="AgentAliases">Agent Aliases</h3>
<pre class="example" data-lang="sequence">
define My complicated agent name as A
define "Another agent name,
and this one's multi-line!" as B
A -> B: this is much easier
A <- B: than writing the whole name
</pre>
</section>
<section>
<h3 id="Markdown">Markdown</h3>
<pre class="example" data-lang="sequence">
define "Name with
**bold** and _italic_" as A
define "Also `code`
and ~strikeout~" as B
A -> B: "_**basic markdown
is supported!**_"
</pre>
</section>
<section>
<h3 id="AlternativeAgentOrdering">Alternative Agent Ordering</h3>
<pre class="example" data-lang="sequence">
define Baz, Foo
Foo -> Bar
Bar -> Baz
</pre>
</section>
<section>
<h3 id="AgentTypes">Agent Types</h3>
<pre class="example" data-lang="sequence">
begin User, Application, PostgreSQL
User -> +Application
Application -> +PostgreSQL
-PostgreSQL --> Application
-Application --> User
User is a person
PostgreSQL is a database
</pre>
</section>
<section>
<h3 id="AsynchronousCommunication">Asynchronous Communication</h3>
<pre class="example" data-lang="sequence">
begin Initiator as I, Receiver as R
# the '...id' syntax allows connections
# to span multiple lines
I -> ...fin1
...fin1 -> R: FIN
# they can even inter-mix!
R -> ...ack1
R -> ...fin2
...ack1 -> I: ACK
...fin2 -> I: FIN
!I -> ...ack2
...ack2 -> !R: ACK
</pre>
</section>
<section>
<h3 id="LanguageMore">More</h3>
<p>
More features are supported. See the
<a href="." target="_blank" rel="noopener">online editor</a>’s library and autocomplete
features to discover them.
</p>
</section>
<h2 id="BrowserSupport" class="no-forced-break">Browser Support</h2>
<p>
This has been tested in the latest versions of Google Chrome, Mozilla Firefox,
and Apple Safari. Versions of Microsoft Internet Explorer / Edge have not been
tested and probably won’t work. Any bugs found in a supported browser
should be reported in the
<a href="https://github.com/davidje13/SequenceDiagram/issues" target="_blank" rel="noopener">Issue Tracker</a>.
</p>
<h2 id="API">API</h2>
<p>
For more advanced usage, an API is available:
</p>
<div id="hold1" class="right"></div>
<pre data-lang="javascript" class="print-reduced">
import { SequenceDiagram } from 'svg-sequence-diagram';
// or const { SequenceDiagram } = require('svg-sequence-diagram');
var diagram = new SequenceDiagram();
diagram.set('A -> B\nB -> A');
document.body.appendChild(diagram.dom());
// Highlight elements created in line 1 (0-based)
diagram.setHighlight(1);
</pre>
<h3 id="API_Constructor">Constructor</h3>
<pre data-lang="javascript">
diagram = new SequenceDiagram(code, options);
diagram = new SequenceDiagram(code);
diagram = new SequenceDiagram(options);
diagram = new SequenceDiagram();
</pre>
<p>
Creates a new SequenceDiagram object. Options is an object which can contain:
</p>
<ul>
<li><code>code</code>: Alternative way of specifying code, instead of using a
separate argument.</li>
<li><code>container</code>: DOM node to append the diagram to (defaults to
null).</li>
<li><code>document</code>: Document object to base the diagram in (defaults to
container's document, or <code>window.document</code>).</li>
<li><code>textSizerFactory</code>: Function which returns an object capable of
measuring text (defaults to wrapping <code>getComputedTextLength</code>).</li>
<li><code>themes</code>: List of themes to make available to the diagram
(defaults to globally registered themes).</li>
<li><code>namespace</code>: Each diagram on a page must have a unique namespace.
By default a unique namespace is generated, but if you want something specific,
enter it here.</li>
<li><code>interactive</code>: If <code>true</code>, will automatically call
<code>addInteractivity</code> when constructing the diagram.</li>
</ul>
<h3 id="API_clone">.clone</h3>
<pre data-lang="javascript">
newDiagram = diagram.clone(options);
newDiagram = diagram.clone();
</pre>
<p>
Creates a copy of the diagram. If options are given, they will override the
current diagram’s state (options is passed to the constructor of the new
object, so all the same options are available). Note that by default, the
<code>namespace</code> will not be cloned (a new unique namespace will be
generated). Also the <code>container</code> will not be cloned; you will need
to specify one explicitly or manually attach the new diagram at a later point.
</p>
<h3 id="API_set">.set</h3>
<pre data-lang="javascript">
diagram.set(code);
</pre>
<p>
Changes the code for the diagram and causes a re-render.
</p>
<h3 id="API_process">.process</h3>
<pre data-lang="javascript">
processed = diagram.process(code);
</pre>
<p>
Processes the given code but does not render it. Causes no change to the
diagram object. This is mostly useful for debounced rendering with immediate
error notifications. The resulting object can be passed to
<a href="#API_render"><code>render</code></a> at a later point.
</p>
<h3 id="API_render">.render</h3>
<pre data-lang="javascript">
diagram.render();
diagram.render(processed);
</pre>
<p>
Forces a re-render of the diagram. Typically this happens automatically.
Optionally, the result of an earlier call to
<a href="#API_process"><code>process</code></a> can be provided.
</p>
<h3 id="API_addTheme">.addTheme</h3>
<pre data-lang="javascript">
diagram.addTheme(theme);
</pre>
<p>
Make a new theme available to the diagram. Any unrecognised themes are replaced
with the default theme.
</p>
<p>
The theme API has not been finalised yet, so this method is not typically
useful.
</p>
<h3 id="API_getThemeNames">.getThemeNames</h3>
<pre data-lang="javascript">
names = diagram.getThemeNames();
</pre>
<p>
Returns a list of names of themes which are available to this diagram. These
can be specified in a <code>theme <name></code> line in the code.
</p>
<h3 id="API_getThemes">.getThemes</h3>
<pre data-lang="javascript">
themes = diagram.getThemes();
</pre>
<p>
Returns a list of themes which are available to this diagram.
</p>
<h3 id="API_addInteractivity">.addInteractivity</h3>
<div class="right">
<pre class="sequence-diagram" data-lang="sequence" data-sd-interactive>
begin A, B
if bored
A -> +B
-B --> A
end
if still bored
A -> +B
-B --> A
end
</pre>
</div>
<pre data-lang="javascript">
diagram.addInteractivity();
</pre>
<p>
Makes the rendered diagram interactive. Currently this means adding a click
listener to any groups which causes them to collapse / expand. Try clicking on
the example to the right.
</p>
<p>The example here has CSS styling applied:</p>
<pre data-lang="css">
.region.collapsed,
.region.expanded {
cursor: pointer;
user-select: none;
}
.region.collapsed:hover .outline,
.region.expanded:hover .outline {
fill: rgba(255, 128, 0, 0.5);
}
</pre>
<p>It is also possible to enable interactivity using a HTML attribute:</p>
<pre data-lang="text/html">
<pre class="sequence-diagram" data-sd-interactive>
A -> +B
if something
-B --> A
end
</pre>
</pre>
<h3 id="API_getSVGSynchronous">.getSVGSynchronous</h3>
<pre data-lang="javascript">
svgURL = diagram.getSVGSynchronous(options);
</pre>
<p>
Returns a blob URL which contains the SVG code for the current diagram.
</p>
<p>The options can include:</p>
<ul>
<li><code>size</code>: Object containing optional width, height or zoom to
specify in the SVG</code>.</li>
</ul>
<h3 id="API_getSVG">.getSVG</h3>
<pre data-lang="javascript">
diagram.getSVG(options).then(({url, latest}) => { ... });
</pre>
<p>
Asynchronous version of
<a href="#API_getSVGSynchronous"><code>getSVGSynchronous</code></a>. This is
provided for compatibility with <a href="#API_getPNG"><code>getPNG</code></a>,
which has no synchronous equivalent.
</p>
<p>The options can include:</p>
<ul>
<li><code>size</code>: Object containing optional width, height or zoom to
specify in the SVG</code>.</li>
</ul>
<p>The callback receives an object containing:</p>
<ul>
<li><code>url</code>: The URL of the generated blob.</li>
<li><code>latest</code>: True if the URL given is still valid; subsequent calls
to this method will invalidate previous URLs.</li>
</ul>
<h3 id="API_getPNG">.getPNG</h3>
<pre data-lang="javascript">
diagram.getPNG(options).then(({url, latest}) => { ... });
</pre>
<p>
Generates a PNG image and returns a blob URL.
</p>
<p>The options can include:</p>
<ul>
<li><code>resolution</code>: Desired pixels-per-unit.</li>
<li><code>size</code>: Object containing optional width, height or zoom to
render the image at (defaults to the unit size of the diagram). The final
output will have size <code>width * resolution</code> ×
<code>height * resolution</code>.</li>
</ul>
<p>The callback receives an object containing:</p>
<ul>
<li><code>url</code>: The URL of the generated blob.</li>
<li><code>latest</code>: True if the URL given is still valid; subsequent calls
to this method will invalidate previous URLs.</li>
</ul>
<h3 id="API_getSize">.getSize</h3>
<pre data-lang="javascript">
size = diagram.getSize();
</pre>
<p>
Returns an object containing <code>width</code> and <code>height</code>
properties, corresponding to the size of the diagram in units.
</p>
<h3 id="API_getTitle">.getTitle</h3>
<pre data-lang="javascript">
title = diagram.getTitle();
</pre>
<p>
Returns the document title as a string. All formatting is lost, and
newlines are replaced with spaces. Returns a blank string if no title is set.
</p>
<h3 id="API_setContainer">.setContainer</h3>
<pre data-lang="javascript">
diagram.setContainer(node);
</pre>
<p>
Same as calling <code>node.appendChild(diagram.dom())</code>.
</p>
<h3 id="API_dom">.dom</h3>
<pre data-lang="javascript">
node = diagram.dom();
</pre>
<p>
Returns the base SVG element which the diagram has been rendered into.
</p>
<h3 id="API_setHighlight">.setHighlight</h3>
<pre data-lang="javascript">
diagram.setHighlight(line);
diagram.setHighlight();
</pre>
<p>
Marks elements generated by the specified line with a "focus" CSS class, which
can be used to style them. Only one line can be highlighted at a time. Calling
with no parameter (or <code>null</code>) will remove the highlighting.
</p>
<p>
The outline effect seen in the editor can be achieved by targetting
<code>.focus .outline</code>. All elements contain an element with the class
"outline", which defines a simple shape surrounding the entire element. For
example:
</p>
<pre data-lang="css">
.region.focus .outline {
stroke-width: 5px;
stroke: rgba(255, 128, 0, 0.5);
}
</pre>
<h3 id="API_setCollapsed">.setCollapsed</h3>
<pre data-lang="javascript">
diagram.setCollapsed(line, collapsed, options);
diagram.setCollapsed(line, collapsed);
</pre>
<p>
Marks the given line as collapsed or non-collapsed. If an element defined at
that line can be collapsed, it will be modified during the next render. Returns
true if a change occurred, or false if the line already had the requested state.
</p>
<p><code>line</code> can also be an array of lines.</p>
<p>
By default, calling this method will trigger an automatic render (unless called
as a no-op). This can be disabled by passing <code>{render: false}</code> in the
options argument.
</p>
<h3 id="API_isCollapsed">.isCollapsed</h3>
<pre data-lang="javascript">
collapsed = diagram.isCollapsed(line);
</pre>
<p>
Returns true if the given line is marked as collapsed, regardless of whether
that line being collapsed has a meaningful impact on the rendered document.
</p>
<h3 id="API_collapse">.collapse</h3>
<pre data-lang="javascript">
diagram.collapse(line, options);
diagram.collapse(line);
</pre>
<p>
Shorthand for <code>.setCollapsed(line, true, options)</code>.
</p>
<h3 id="API_expand">.expand</h3>
<pre data-lang="javascript">
diagram.expand(line, options);
diagram.expand(line);
</pre>
<p>
Shorthand for <code>.setCollapsed(line, false, options)</code>.
</p>
<h3 id="API_toggleCollapsed">.toggleCollapsed</h3>
<pre data-lang="javascript">
diagram.toggleCollapsed(line, options);
diagram.toggleCollapsed(line);
</pre>
<p>
Toggles the given line’s collapsed status by calling
<code>.setCollapsed</code>.
</p>
<h3 id="API_expandAll">.expandAll</h3>
<pre data-lang="javascript">
diagram.expandAll(options);
diagram.expandAll();
</pre>
<p>
Marks all lines as non-collapsed. Returns true if a change occurred, or false
if all lines were already non-collapsed.
</p>
<p>
By default, calling this method will trigger an automatic render (unless called
as a no-op). This can be disabled by passing <code>{render: false}</code> in the
options argument.
</p>
<h3 id="API_addEventListener">.addEventListener</h3>
<pre data-lang="javascript">
diagram.addEventListener(type, callback);
</pre>
<p>
Registers an event listener. The available events are:</p>
<ul>
<li><code>mouseover</code>: called when the mouse enters a region of the diagram
(e.g. a note).</li>
<li><code>mouseout</code>: called when the mouse leaves a region of the
diagram.</li>
<li><code>click</code>: called when the user clicks on a region of the
diagram.</li>
<li><code>dblclick</code>: called when the user double-clicks on a region of the
diagram.</li>
<li><code>render</code>: called when the diagram finishes rendering. Receives
the sequence diagram object as an argument.</li>
</ul>
<p>All mouse events are invoked with a single parameter: the element. This
object contains:</p>
<ul>
<li><code>ln</code>: the line number of the source code which defined the
element.</li>
<li><code>type</code>: a string representing the type of the element.</li>
<li>Other fields which define the element (exact fields vary by type).</li>
</ul>
<h3 id="API_removeEventListener">.removeEventListener</h3>
<pre data-lang="javascript">
diagram.removeEventListener(type, callback);
</pre>
<p>
Removes a previously registered event listener.
</p>
<h3 id="API_removeAllEventListeners">.removeAllEventListeners</h3>
<pre data-lang="javascript">
diagram.removeAllEventListeners(type);
diagram.removeAllEventListeners();
</pre>
<p>
Removes all registered event listeners for a given type, or all event listeners
for all types.
</p>
<h2 id="SimilarTools">Similar Tools</h2>
<p>
There are quite a lot of sequence diagram drawing tools available. If this one
doesn’t fit your needs for whatever reason, you might want to take a look
at the alternatives: (but also feel free to raise feature requests in the
<a href="https://github.com/davidje13/SequenceDiagram/issues" target="_blank" rel="noopener">issue tracker</a>!)
</p>
<ul>
<li><a href="https://www.websequencediagrams.com/" target="_blank" rel="noopener">websequencediagrams.com</a>
is a commercial offering which inspired the syntax of this project and many
others. It has a wide range of themes but limited functionality. Also offers a
hosted image generation service.</li>
<li><a href="https://github.com/bramp/js-sequence-diagrams" target="_blank" rel="noopener">js-sequence-diagrams</a>
is a Javascript library which has wider browser support via snap.svg but very
limited functionality.</li>
<li><a href="https://github.com/knsv/mermaid" target="_blank" rel="noopener">mermaid</a>
is a Javascript library and online editor which can render multiple types of UML
diagram, including simple sequence diagrams.</li>
<li><a href="https://github.com/aivarsk/scruffy" target="_blank" rel="noopener">Scruffy UML</a>
is a Python library which can render multiple types of UML diagram, including
simple sequence diagrams, from the commandline. Uses yUML syntax rather than the
human friendly syntax used by most other projects.</li>
<li><a href="https://github.com/plantuml/plantuml" target="_blank" rel="noopener">PlantUML</a>
is a Java project and online editor which can render multiple types of UML
diagram, including sequence diagrams. Has a good range of features and allows a
high degree of customisation (e.g. diagram colours).</li>
</ul>
<h2 id="Thanks">Thanks</h2>
<p>
Thanks to the other tools mentioned above for inspiring parts of the syntax of
this project, and to
<a href="https://fonts.google.com/specimen/Handlee" target="_blank" rel="noopener">the Handlee font</a>
which is used in the sketch theme.
</p>
<pre class="sequence-diagram">
theme sketch
begin User, SequenceDiagram as SD, Parser, Generator, Renderer
User -> +SD: code
SD -> +Parser: code
-Parser --> SD: parsed
SD -> +Generator: parsed
-Generator --> SD: generated
-SD -> +Renderer: generated
-Renderer -> *DOM: SVG
User <~> DOM: interaction
terminators box
</pre>
<nav>
<a href="." target="_blank" rel="noopener">Online Editor</a><a href="https://github.com/davidje13/SequenceDiagram" target="_blank" rel="noopener">GitHub</a>
</nav>
</article>
</body>
</html>