{"id":13534985,"url":"https://bramp.github.io/js-sequence-diagrams/","last_synced_at":"2025-04-02T00:31:12.731Z","repository":{"id":5533937,"uuid":"6736646","full_name":"bramp/js-sequence-diagrams","owner":"bramp","description":"Draws simple SVG sequence diagrams from textual representation of the diagram","archived":false,"fork":false,"pushed_at":"2022-09-21T12:42:11.000Z","size":2272,"stargazers_count":7828,"open_issues_count":111,"forks_count":1071,"subscribers_count":241,"default_branch":"master","last_synced_at":"2025-03-25T22:13:30.408Z","etag":null,"topics":["javascript","sequence-diagram","svg"],"latest_commit_sha":null,"homepage":"https://bramp.github.io/js-sequence-diagrams/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bramp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-17T15:33:46.000Z","updated_at":"2025-03-23T22:21:15.000Z","dependencies_parsed_at":"2022-07-20T15:49:50.805Z","dependency_job_id":null,"html_url":"https://github.com/bramp/js-sequence-diagrams","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fjs-sequence-diagrams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fjs-sequence-diagrams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fjs-sequence-diagrams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fjs-sequence-diagrams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bramp","download_url":"https://codeload.github.com/bramp/js-sequence-diagrams/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246724827,"owners_count":20823545,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","sequence-diagram","svg"],"created_at":"2024-08-01T08:00:48.041Z","updated_at":"2025-04-02T00:31:12.638Z","avatar_url":"https://github.com/bramp.png","language":"JavaScript","funding_links":[],"categories":["Image","Mock up and UI Design"],"sub_categories":["Diagram/Flowchart"],"readme":"JS Sequence Diagrams [![Bower](https://img.shields.io/bower/v/js-sequence-diagrams.svg)](https://libraries.io/bower/js-sequence-diagrams) [![Build Status](https://img.shields.io/travis/bramp/js-sequence-diagrams.svg)](https://travis-ci.org/bramp/js-sequence-diagrams) [![Code Climate](https://img.shields.io/codeclimate/github/bramp/js-sequence-diagrams.svg)](https://codeclimate.com/github/bramp/js-sequence-diagrams) [![Libraries.io](https://img.shields.io/librariesio/github/bramp/js-sequence-diagrams.svg)](https://libraries.io/github/bramp/js-sequence-diagrams) ![License](https://img.shields.io/npm/l/js-sequence-diagrams.svg)\n=============================================\n**Generates UML sequence diagrams from simple text**  \n\u003chttps://bramp.github.io/js-sequence-diagrams/\u003e\n\nby [Andrew Brampton](https://bramp.net) 2012-2017\n\n\nExample\n-------\nWe turn\n\n    Alice-\u003eBob: Hello Bob, how are you?\n    Note right of Bob: Bob thinks\n    Bob--\u003eAlice: I am good thanks!\n\ninto\n\n![Sample generated UML diagram](https://bramp.github.io/js-sequence-diagrams/images/sample.svg)\n\nRequirements\n------------\nYou 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/).\n\n\nInstallation\n----------------------\n\n### bower\n\nRun `bower install bramp/js-sequence-diagrams` and include the scripts below:\n\n```html\n\u003cscript src=\"{{ bower directory }}/bower-webfontloader/webfont.js\" /\u003e\n\u003cscript src=\"{{ bower directory }}/snap.svg/dist/snap.svg-min.js\" /\u003e\n\u003cscript src=\"{{ bower directory }}/underscore/underscore-min.js\" /\u003e\n\u003cscript src=\"{{ bower directory }}/js-sequence-diagrams/dist/sequence-diagram-min.js\" /\u003e\n```\n\nalso import the CSS if you plan to use the hand drawn theme:\n \n```html\n\u003clink href=\"{{ bower directory }}/js-sequence-diagrams/dist/sequence-diagram-min.css\" rel=\"stylesheet\" /\u003e\n```\n\nNot using bower? No problem. Just download the dependencies, and include them yourself.\nIf you plan to use the hand draw theme, don't forget to put the two fontfiles in your css folder: \n /fonts/daniel/danielbd.woff and /fonts/daniel/danielbd.woff2\n\nUsage\n-----\n\nYou can use the Diagram class like:\n\n```html\n\u003cdiv id=\"diagram\"\u003eDiagram will be placed here\u003c/div\u003e\n\u003cscript\u003e \n  var d = Diagram.parse(\"A-\u003eB: Does something\");\n  var options = {theme: 'simple'};\n  d.drawSVG('diagram', options);\n\u003c/script\u003e\n```\n\nor use jQuery to do all the work:\n```html\n\u003cscript src=\"{{ bower directory }}/jquery/dist/jquery.min.js\" /\u003e\n\u003cdiv class=\"diagram\"\u003eA-\u003eB: Message\u003c/div\u003e\n\u003cscript\u003e\n  var options = {theme: 'hand'};\n  $(\".diagram\").sequenceDiagram(options);\n\u003c/script\u003e\n```\n\nFor full examples check out [the demo site](https://bramp.github.io/js-sequence-diagrams/).\n\nOptions\n-------\n\n```javascript\nvar options = {\n    // Change the styling of the diagram, typically one of 'simple', 'hand'. New themes can be registered with registerTheme(...).\n    theme: string,\n\n    // CSS style to apply to the diagram's svg tag. (Only supported if using snap.svg)\n    css_class: string,\n};\n```\n\nStyling\n-------\n\nThe following CSS classes are applied to the SVG diagram when using snap.svg:\n\n* `sequence`: Applies to main SVG tag.\n* `title`: Applied to the title of the diagram.\n* `actor`: Applied to the actors.\n* `signal`: Applied to the signals.\n* `note`: Applied to all notes.\n\nThe diagram can then be customised, for example:\n\n```css\n.signal text {\n    fill: #000000;\n}\n.signal text:hover {\n    fill: #aaaaaa\n}\n.note rect, .note path {\n    fill: #ffff00;\n}\n.title rect, .title path,\n.actor rect, .actor path {\n    fill: #ffffff\n}\n```\n\nRaphaël Deprecation\n-------------------\n\nVersion 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.\n\nTo 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 \n\n```html\n\u003cscript src=\"{{ bower directory }}/raphael/raphael-min.js\"\u003e\u003c/script\u003e\n```\n\nThere are also four transitional themes, 'snapSimple', 'snapHand', 'raphaelSimple', 'raphaelHand', which force the use of either Snap.svg, or Raphaël.\n\nThe plan is to drop support for Raphaël in a future release, simplifying the library, and reducing the file size.\n\n### Adding a Font\n\nRaphael 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.\n\n\nBuild requirements\n------------------\nThe 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.\n\n```bash\nmake\n```\n\nThe Makefile will use npm to install all the dev dependencies, build, and test.\n\nTesting\n-------\n\nWe use [qunit](https://qunitjs.com/) for testing. It can be ran from the command line, or via a browser. The command line actually tests multiple permutations of [lodash](https://lodash.com/), [Underscore](http://underscorejs.org/), and with and without minification.\n\n```bash\nmake test\n...\nGlobal summary:\n┌───────┬───────┬────────────┬────────┬────────┬─────────┐\n│ Files │ Tests │ Assertions │ Failed │ Passed │ Runtime │\n├───────┼───────┼────────────┼────────┼────────┼─────────┤\n│ 1     │ 13    │ 231        │ 0      │ 231    │ 250     │\n└───────┴───────┴────────────┴────────┴────────┴─────────┘\n```\n\nor `make` and then open test/qunit.html in a browser. Finally a simple playground is available at test/test.html.\n\nHow to release\n--------------\n* Make sure all changes checked in\n* Bump version in src/main.js and bower.json\n* ``make clean``\n* ``make``\n* ``git add -f src/main.js bower.json dist/*``\n* ``git commit -m \"Released version 2.x.x\"``\n* ``git push origin master``\n* ``git tag -a v2.x.x -m v2.x.x``\n* ``git push origin v2.x.x``\n\n\nTODO\n----\n* Other themes\n* Automate the release process\n* Testing that checks the generated SVG is correct\n* Improve the hand drawn theme\n  * \"Note left of Bob: \" generates a small empty box.\n  * The font seems to have extra margin at the bottom.\n  * The wiggly lines don't always touch.\n\n* Dozens of other issues on [https://github.com/bramp/js-sequence-diagrams/issues](https://github.com/bramp/js-sequence-diagrams/issues)\n\nContributors\n------------\n\nvia [GitHub](https://github.com/bramp/js-sequence-diagrams/graphs/contributors)\n\nThanks\n------\nThis project makes use of [Jison](https://zaach.github.io/jison/), snap.svg, underscore.js, and the awesome [Daniel font](http://www.dafont.com/daniel.font) (which is free to use for any purpose).\n\nMany thanks to [Web Sequence Diagrams](http://www.websequencediagrams.com/) which greatly inspired this project, and forms the basis for the syntax.\n\nRelated\n-------\n\n* [Web Sequence Diagrams](http://www.websequencediagrams.com/) Server side version with a commercial offering\n* [flowchart.js](https://adrai.github.io/flowchart.js/) A similar project that draws flow charts in the browser\n\n\nLicence (Simplified BSD License)\n-------\n\nCopyright (c) 2012-2017, Andrew Brampton\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/bramp.github.io%2Fjs-sequence-diagrams%2F","html_url":"https://awesome.ecosyste.ms/projects/bramp.github.io%2Fjs-sequence-diagrams%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/bramp.github.io%2Fjs-sequence-diagrams%2F/lists"}