Skip to content

Commit 1ff83e2

Browse files
committedDec 26, 2016
Updated the README.md for v2.
1 parent cb88722 commit 1ff83e2

File tree

2 files changed

+86
-26
lines changed

2 files changed

+86
-26
lines changed
 

‎README.md

+84-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
JS Sequence Diagrams [![Build Status](https://travis-ci.org/bramp/js-sequence-diagrams.svg?branch=master)](https://travis-ci.org/bramp/js-sequence-diagrams)
1+
JS Sequence Diagrams v2 [![Build Status](https://travis-ci.org/bramp/js-sequence-diagrams.svg?branch=master)](https://travis-ci.org/bramp/js-sequence-diagrams)
22
=============================================
33
**Generates UML sequence diagrams from simple text**
44
<https://bramp.github.io/js-sequence-diagrams/>
@@ -16,36 +16,34 @@ We turn
1616

1717
into
1818

19-
![Sample generated UML diagram](http://bramp.github.io/js-sequence-diagrams/images/sample.svg)
19+
![Sample generated UML diagram](https://bramp.github.io/js-sequence-diagrams/images/sample.svg)
2020

2121
Requirements
2222
------------
23-
You will need [Raphaël](http://raphaeljs.com/), [underscore.js](http://underscorejs.org/) (or [lodash](https://lodash.com/)), and optionally [jQuery](https://jquery.com/).
23+
You will need [Snap.svg](http://snapsvg.io/), [Web Font Loader](https://github.com/typekit/webfontloader) (if you wish to use custom fonts), [underscore.js](http://underscorejs.org/) (or [lodash](https://lodash.com/)), and optionally [jQuery](https://jquery.com/).
2424

2525

2626
Installation
2727
----------------------
2828

2929
### bower
3030

31-
Just run `bower install bramp/js-sequence-diagrams` and include the scripts below:
31+
Run `bower install bramp/js-sequence-diagrams` and include the scripts below:
3232

3333
```html
34-
<script src="{{ bower directory }}/raphael/raphael-min.js"></script>
35-
<script src="{{ bower directory }}/underscore/underscore-min.js"></script>
36-
<script src="{{ bower directory }}/js-sequence-diagrams/build/sequence-diagram-min.js"></script>
34+
<script src="{{ bower directory }}/snap.svg/dist/snap.svg-min.js" />
35+
<script src="{{ bower directory }}/underscore/underscore-min.js" />
36+
<script src="{{ bower directory }}/js-sequence-diagrams/build/sequence-diagram-min.js" />
3737
```
3838
39-
### Manually
40-
41-
You can download the dependencies (see requirements above) and include them on your page like so:
42-
39+
also import the CSS if you plan to use the hand drawn theme:
40+
4341
```html
44-
<script src="underscore-min.js"></script>
45-
<script src="raphael-min.js"></script>
46-
<script src="sequence-diagram-min.js"></script>
42+
<link href="{{ bower directory }}/js-sequence-diagrams/build/sequence-diagram-min.css" rel="stylesheet" />
4743
```
4844
45+
Not using bower? No problem. Just download the dependencies, and include them yourself.
46+
4947
Usage
5048
-----
5149
@@ -54,19 +52,83 @@ You can use the Diagram class like:
5452
```html
5553
<div id="diagram">Diagram will be placed here</div>
5654
<script>
57-
var diagram = Diagram.parse("A->B: Does something");
58-
diagram.drawSVG('diagram');
55+
var d = Diagram.parse("A->B: Does something");
56+
var options = {theme: 'simple'};
57+
d.drawSVG('diagram', options);
5958
</script>
6059
```
6160

6261
or use jQuery to do all the work:
6362
```html
6463
<div class="diagram">A->B: Message</div>
6564
<script>
66-
$(".diagram").sequenceDiagram({theme: 'hand'});
65+
var options = {theme: 'hand'};
66+
$(".diagram").sequenceDiagram(options);
6767
</script>
6868
```
6969

70+
For full examples check out [the demo site](https://bramp.github.io/js-sequence-diagrams/).
71+
72+
Options
73+
-------
74+
75+
```javascript
76+
var options = {
77+
// Change the styling of the diagram, typically one of 'simple', 'hand'. New themes can be registered with registerTheme(...).
78+
theme: string,
79+
80+
// CSS style to apply to the diagram's svg tag. (Only supported if using snap.svg)
81+
css_class: string,
82+
};
83+
```
84+
85+
Styling
86+
-------
87+
88+
The following CSS classes are applied to the SVG diagram when using snap.svg:
89+
90+
* `sequence`: Applies to main SVG tag.
91+
* `title`: Applied to the title of the diagram.
92+
* `actor`: Applied to the actors.
93+
* `signal`: Applied to the signals.
94+
* `note`: Applied to all notes.
95+
96+
The diagram can then be customised, for example:
97+
98+
```css
99+
.signal text {
100+
fill: #000000;
101+
}
102+
.signal text:hover {
103+
fill: #aaaaaa
104+
}
105+
.note rect, .note path {
106+
fill: #ffff00;
107+
}
108+
.title rect, .title path,
109+
.actor rect, .actor path {
110+
fill: #ffffff
111+
}
112+
```
113+
114+
Raphaël Deprecation
115+
-------------------
116+
117+
Version 1.x of this library used [Raphaël](http://raphaeljs.com/) for drawing the diagrams, however, Raphaël had some limitations, and since disappeared from the Internet. We've decided to move to [Snap.svg](http://snapsvg.io/), which is a pure SVG implementation, instead of Raphaël which in addition to SVG, also supported VML (on Internet Explorer). This support of VML made it impossible to use some newer SVG capabilities. Native SVG allows us to use CSS styling, better font support, animations and more.
118+
119+
To aid in the transition Version 2.x will support both Raphaël and Snap.svg (preferring Snap.svg). If you include Raphaël instead of snap.svg, it will default to using Raphaël as the rendering library. For example
120+
121+
```html
122+
<script src="{{ bower directory }}/raphael/raphael-min.js"></script>
123+
```
124+
125+
The plan is to drop support for Raphaël in a future release, simplifying the library, and reducing the file size.
126+
127+
### Adding a Font
128+
129+
Raphael requires Cufon style fonts. Find the font you want in ttf or otf format, visit [Cufon's site](http://cufon.shoqolate.com/generate/) and process it into a javascript file. Then ensure the font is included via the HTML, or recompile after altering main.js. So far only the hand drawn font, Daniel Bold, has been included.
130+
131+
70132
Build requirements
71133
------------------
72134
The build is managed by a Makefile, and uses various tools available from npm. Thus both `make` and [npm](https://github.com/npm/npm) are required, and can easily be installed on any Linux or Mac machine.
@@ -107,17 +169,13 @@ How to release
107169
* ``git tag -a v1.x.x -m v1.x.x``
108170
* ``git push origin v1.x.x``
109171

110-
Adding a Font
111-
-------------
112-
113-
Raphael requires Cufon style fonts. Find the font you want in ttf or otf format, visit [Cufon's site](http://cufon.shoqolate.com/generate/) and process it into a javascript file. Then ensure the font is included via the HTML, or recompile after altering main.js. So far only the hand drawn font, Daniel Bold, has been included.
114-
115172

116173
TODO
117174
----
118175
* Other themes
119-
* Rethink the use of Raphael. Due to its support of VML (which I don't care about), it makes many things harder. For example, font support, css styling, etc. Perhaps draw the SVG by hand, or find a small helper library
120176
* Automate the release process
177+
* Testing that checks the generated SVG is correct
178+
* Improve the hand drawn theme
121179
* Dozens of other issues on https://github.com/bramp/js-sequence-diagrams/issues
122180

123181
Contributors
@@ -127,15 +185,16 @@ via [GitHub](https://github.com/bramp/js-sequence-diagrams/graphs/contributors)
127185

128186
Thanks
129187
------
130-
This project makes use of [Jison](http://zaach.github.io/jison/), Raphaël, underscore.js, and the awersome [Daniel font](http://www.dafont.com/daniel.font) (which is free to use for any purpose).
188+
This project makes use of [Jison](https://zaach.github.io/jison/), snap.svg, underscore.js, and the awersome [Daniel font](http://www.dafont.com/daniel.font) (which is free to use for any purpose).
131189

132190
Many thanks to [Web Sequence Diagrams](http://www.websequencediagrams.com/) which greatly inspired this project, and forms the basis for the syntax.
133191

134192
Related
135193
-------
136194

137195
* [Web Sequence Diagrams](http://www.websequencediagrams.com/) Server side version with a commercial offering
138-
* [flowchart.js](http://adrai.github.io/flowchart.js/) A similar project that draws flow charts in the browser
196+
* [flowchart.js](https://adrai.github.io/flowchart.js/) A similar project that draws flow charts in the browser
197+
139198

140199
Licence (Simplified BSD License)
141200
-------

‎fonts/daniel/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ I (bramp) fixed the backslash issues by just flipping the character, and removed
1616
Check out the test/font_test.html, to see all valid glyths.
1717

1818
## Raphael
19-
For Raphael the TTF fonts were then converted to cufon format, using [this site](http://cufon.shoqolate.com/generate/).0
19+
For Raphael the TTF fonts were then converted to cufon format, using [this site](http://cufon.shoqolate.com/generate/).
20+
2021
## Snap.svg
2122
Snap uses normal CSS styled fonts. In this case, I used [font squirell](http://www.fontsquirrel.com/tools/webfont-generator) to convert to daniel OTF fonts to WOFF/WOFF2 formats, which is supported across modern browsers.
2223

0 commit comments

Comments
 (0)
Please sign in to comment.