mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-27 08:54:09 +01:00
Merge remote-tracking branch 'origin/master'
Conflicts: dist/mermaid.full.js dist/mermaid.full.min.js dist/mermaid.slim.js dist/mermaid.slim.min.js src/diagrams/gantt/ganttRenderer.js test/gantt.html
This commit is contained in:
@@ -383,5 +383,4 @@
|
|||||||
## [0.1.0](https://github.com/knsv/mermaid/tree/0.1.0) (2014-11-16)
|
## [0.1.0](https://github.com/knsv/mermaid/tree/0.1.0) (2014-11-16)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
||||||
1
dist/mermaid.forest.css
vendored
1
dist/mermaid.forest.css
vendored
@@ -4,6 +4,7 @@
|
|||||||
.mermaid .label {
|
.mermaid .label {
|
||||||
color: #333333;
|
color: #333333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.node rect,
|
.node rect,
|
||||||
.node circle,
|
.node circle,
|
||||||
.node polygon {
|
.node polygon {
|
||||||
|
|||||||
10
lib/cli.js
10
lib/cli.js
@@ -24,6 +24,7 @@ function cli(options) {
|
|||||||
, verbose: 'v'
|
, verbose: 'v'
|
||||||
, phantomPath: 'e'
|
, phantomPath: 'e'
|
||||||
, sequenceConfig: 'c'
|
, sequenceConfig: 'c'
|
||||||
|
, ganttConfig: 'g'
|
||||||
, css: 't'
|
, css: 't'
|
||||||
}
|
}
|
||||||
, 'boolean': ['help', 'png', 'svg']
|
, 'boolean': ['help', 'png', 'svg']
|
||||||
@@ -45,6 +46,7 @@ function cli(options) {
|
|||||||
, " -e --phantomPath Specify the path to the phantomjs executable"
|
, " -e --phantomPath Specify the path to the phantomjs executable"
|
||||||
, " -t --css Specify the path to a CSS file to be included when processing output"
|
, " -t --css Specify the path to a CSS file to be included when processing output"
|
||||||
, " -c --sequenceConfig Specify the path to the file with the configuration to be applied in the sequence diagram"
|
, " -c --sequenceConfig Specify the path to the file with the configuration to be applied in the sequence diagram"
|
||||||
|
, " -g --ganttConfig Specify the path to the file with the configuration to be applied in the gantt diagram"
|
||||||
, " -h --help Show this message"
|
, " -h --help Show this message"
|
||||||
, " -v --verbose Show logging"
|
, " -v --verbose Show logging"
|
||||||
, " --version Print version and quit"
|
, " --version Print version and quit"
|
||||||
@@ -74,7 +76,7 @@ cli.prototype.parse = function(argv, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ensure that parameter-expecting options have parameters
|
// ensure that parameter-expecting options have parameters
|
||||||
;['outputDir', 'phantomPath', 'sequenceConfig', 'css'].forEach(function(i) {
|
;['outputDir', 'phantomPath', 'sequenceConfig', 'ganttConfig', 'css'].forEach(function(i) {
|
||||||
if(typeof options[i] !== 'undefined') {
|
if(typeof options[i] !== 'undefined') {
|
||||||
if (typeof options[i] !== 'string' || options[i].length < 1) {
|
if (typeof options[i] !== 'string' || options[i].length < 1) {
|
||||||
this.errors.push(new Error(i + " expects a value."))
|
this.errors.push(new Error(i + " expects a value."))
|
||||||
@@ -94,6 +96,12 @@ cli.prototype.parse = function(argv, next) {
|
|||||||
options.sequenceConfig = checkConfig(options.sequenceConfig)
|
options.sequenceConfig = checkConfig(options.sequenceConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (options.ganttConfig) {
|
||||||
|
options.ganttConfig = checkConfig(options.ganttConfig)
|
||||||
|
console.log('Got conf'+options.ganttConfig);
|
||||||
|
}
|
||||||
|
|
||||||
if (options.css) {
|
if (options.css) {
|
||||||
try {
|
try {
|
||||||
options.css = fs.readFileSync(options.css, 'utf8')
|
options.css = fs.readFileSync(options.css, 'utf8')
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ function processMermaid(files, _options, _next) {
|
|||||||
, options.svg
|
, options.svg
|
||||||
, options.css || ''
|
, options.css || ''
|
||||||
, options.sequenceConfig
|
, options.sequenceConfig
|
||||||
|
, options.ganttConfig
|
||||||
, options.verbose
|
, options.verbose
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -28,18 +28,24 @@ var system = require('system')
|
|||||||
, fs = require('fs')
|
, fs = require('fs')
|
||||||
, webpage = require('webpage')
|
, webpage = require('webpage')
|
||||||
|
|
||||||
|
|
||||||
var page = webpage.create()
|
var page = webpage.create()
|
||||||
, files = phantom.args.slice(6, phantom.args.length)
|
, files = phantom.args.slice(7, phantom.args.length)
|
||||||
, options = {
|
, options = {
|
||||||
outputDir: phantom.args[0]
|
outputDir: phantom.args[0]
|
||||||
, png: phantom.args[1] === 'true' ? true : false
|
, png: phantom.args[1] === 'true' ? true : false
|
||||||
, svg: phantom.args[2] === 'true' ? true : false
|
, svg: phantom.args[2] === 'true' ? true : false
|
||||||
, css: phantom.args[3] !== '' ? phantom.args[3] : '* { margin: 0; padding: 0; }'
|
, css: phantom.args[3] !== '' ? phantom.args[3] : '* { margin: 0; padding: 0; }'
|
||||||
, sequenceConfig: phantom.args[4]
|
, sequenceConfig: phantom.args[4]
|
||||||
, verbose: phantom.args[5] === 'true' ? true : false
|
, ganttConfig: phantom.args[5]
|
||||||
|
, verbose: phantom.args[6] === 'true' ? true : false
|
||||||
}
|
}
|
||||||
, log = logger(options.verbose)
|
, log = logger(options.verbose)
|
||||||
|
|
||||||
|
|
||||||
|
console.log('options');
|
||||||
|
console.log(options.ganttConfig);
|
||||||
|
|
||||||
page.content = [
|
page.content = [
|
||||||
'<html>'
|
'<html>'
|
||||||
, '<head>'
|
, '<head>'
|
||||||
@@ -68,8 +74,9 @@ files.forEach(function(file) {
|
|||||||
// look like it. we need to serialize then unserialize the svgContent that's
|
// look like it. we need to serialize then unserialize the svgContent that's
|
||||||
// taken from the DOM
|
// taken from the DOM
|
||||||
svgContent = page.evaluate(executeInPage, {
|
svgContent = page.evaluate(executeInPage, {
|
||||||
contents: contents,
|
contents : contents,
|
||||||
sequenceConfig: options.sequenceConfig
|
ganttConfig : options.ganttConfig,
|
||||||
|
sequenceConfig : options.sequenceConfig
|
||||||
})
|
})
|
||||||
oDOM = oParser.parseFromString(svgContent, "text/xml")
|
oDOM = oParser.parseFromString(svgContent, "text/xml")
|
||||||
|
|
||||||
@@ -193,6 +200,7 @@ function executeInPage(data) {
|
|||||||
var xmlSerializer = new XMLSerializer()
|
var xmlSerializer = new XMLSerializer()
|
||||||
, contents = data.contents
|
, contents = data.contents
|
||||||
, sequenceConfig = data.sequenceConfig
|
, sequenceConfig = data.sequenceConfig
|
||||||
|
, ganttConfig = data.ganttConfig
|
||||||
, toRemove
|
, toRemove
|
||||||
, el
|
, el
|
||||||
, elContent
|
, elContent
|
||||||
@@ -221,6 +229,17 @@ function executeInPage(data) {
|
|||||||
document.body.appendChild(sc)
|
document.body.appendChild(sc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(typeof ganttConfig !== undefined && ganttConfig !== 'undefined'){
|
||||||
|
console.log('Got ganttConfig');
|
||||||
|
sc = document.createElement("script")
|
||||||
|
scContent = document.createTextNode('mermaid.ganttConfig = JSON.parse(' + JSON.stringify(ganttConfig) + ');')
|
||||||
|
sc.appendChild(scContent)
|
||||||
|
|
||||||
|
document.body.appendChild(sc)
|
||||||
|
}else{
|
||||||
|
console.log('No gantt config');
|
||||||
|
}
|
||||||
|
|
||||||
mermaid.init();
|
mermaid.init();
|
||||||
|
|
||||||
svg = document.querySelector('svg')
|
svg = document.querySelector('svg')
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ module.exports.draw = function (text, id) {
|
|||||||
var h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding;
|
var h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding;
|
||||||
|
|
||||||
elem.style.height = h + 'px';
|
elem.style.height = h + 'px';
|
||||||
elem.height = h;
|
elem.setAttribute('height', h);
|
||||||
var svg = d3.select('#' + id);
|
var svg = d3.select('#' + id);
|
||||||
|
|
||||||
// http://codepen.io/anon/pen/azLvWR
|
// http://codepen.io/anon/pen/azLvWR
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ var actors = {};
|
|||||||
var actorKeys = [];
|
var actorKeys = [];
|
||||||
var messages = [];
|
var messages = [];
|
||||||
var notes = [];
|
var notes = [];
|
||||||
|
|
||||||
exports.addActor = function(id,name,description){
|
exports.addActor = function(id,name,description){
|
||||||
//console.log('Adding actor: '+id);
|
//console.log('Adding actor: '+id);
|
||||||
actors[id] = {name:name, description:description};
|
actors[id] = {name:name, description:description};
|
||||||
@@ -16,6 +17,9 @@ exports.addMessage = function(idFrom, idTo, message, answer){
|
|||||||
messages.push({from:idFrom, to:idTo, message:message, answer:answer});
|
messages.push({from:idFrom, to:idTo, message:message, answer:answer});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
exports.addSignal = function(idFrom, idTo, message, messageType){
|
exports.addSignal = function(idFrom, idTo, message, messageType){
|
||||||
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
|
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
|
||||||
messages.push({from:idFrom, to:idTo, message:message, type:messageType});
|
messages.push({from:idFrom, to:idTo, message:message, type:messageType});
|
||||||
@@ -41,21 +45,20 @@ exports.clear = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.LINETYPE = {
|
exports.LINETYPE = {
|
||||||
SOLID : 0,
|
SOLID : 0 ,
|
||||||
DOTTED : 1,
|
DOTTED : 1 ,
|
||||||
NOTE : 2,
|
NOTE : 2 ,
|
||||||
SOLID_CROSS : 3,
|
SOLID_CROSS : 3 ,
|
||||||
DOTTED_CROSS: 4,
|
DOTTED_CROSS : 4 ,
|
||||||
SOLID_OPEN : 5,
|
SOLID_OPEN : 5 ,
|
||||||
DOTTED_OPEN : 6,
|
DOTTED_OPEN : 6 ,
|
||||||
LOOP_START : 10,
|
LOOP_START : 10 ,
|
||||||
LOOP_END : 11,
|
LOOP_END : 11 ,
|
||||||
ALT_START : 12,
|
ALT_START : 12 ,
|
||||||
ALT_ELSE : 13,
|
ALT_ELSE : 13 ,
|
||||||
ALT_END : 14,
|
ALT_END : 14 ,
|
||||||
OPT_START : 15,
|
OPT_START : 15 ,
|
||||||
OPT_END : 16
|
OPT_END : 16
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.ARROWTYPE = {
|
exports.ARROWTYPE = {
|
||||||
|
|||||||
@@ -217,15 +217,15 @@ exports.getTextObj = function(){
|
|||||||
|
|
||||||
exports.getNoteRect = function(){
|
exports.getNoteRect = function(){
|
||||||
var rect = {
|
var rect = {
|
||||||
x: 0,
|
x : 0,
|
||||||
y: 0,
|
y : 0,
|
||||||
fill: '#EDF2AE',
|
fill : '#EDF2AE',
|
||||||
stroke: '#666',
|
stroke : '#666',
|
||||||
width: 100,
|
width : 100,
|
||||||
anchor:'start',
|
anchor : 'start',
|
||||||
height: 100,
|
height : 100,
|
||||||
rx: 0,
|
rx : 0,
|
||||||
ry: 0
|
ry : 0
|
||||||
};
|
};
|
||||||
return rect;
|
return rect;
|
||||||
};
|
};
|
||||||
|
|||||||
22
src/main.js
22
src/main.js
@@ -186,21 +186,22 @@ var equals = function (val, variable){
|
|||||||
};
|
};
|
||||||
|
|
||||||
global.mermaid = {
|
global.mermaid = {
|
||||||
startOnLoad:true,
|
startOnLoad: true,
|
||||||
htmlLabels:true,
|
htmlLabels: true,
|
||||||
init:function(sequenceConfig, nodes){
|
|
||||||
|
init: function(sequenceConfig, nodes) {
|
||||||
init.apply(null, arguments);
|
init.apply(null, arguments);
|
||||||
},
|
},
|
||||||
version:function(){
|
version: function() {
|
||||||
return exports.version();
|
return exports.version();
|
||||||
},
|
},
|
||||||
getParser:function(){
|
getParser: function() {
|
||||||
return flow.parser;
|
return flow.parser;
|
||||||
},
|
},
|
||||||
parse:function(text){
|
parse: function(text) {
|
||||||
return parse(text);
|
return parse(text);
|
||||||
},
|
},
|
||||||
parseError:function(err,hash){
|
parseError: function(err, hash) {
|
||||||
console.log('Mermaid Syntax error:');
|
console.log('Mermaid Syntax error:');
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
@@ -222,12 +223,12 @@ exports.contentLoaded = function(){
|
|||||||
if (typeof mermaid_config !== 'undefined') {
|
if (typeof mermaid_config !== 'undefined') {
|
||||||
// Check if property startOnLoad is set
|
// Check if property startOnLoad is set
|
||||||
if (equals(true, mermaid_config.startOnLoad)) {
|
if (equals(true, mermaid_config.startOnLoad)) {
|
||||||
global.mermaid.init(mermaid.sequenceConfig);
|
global.mermaid.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// No config found, do autostart in this simple case
|
// No config found, do autostart in this simple case
|
||||||
global.mermaid.init(mermaid.sequenceConfig);
|
global.mermaid.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,3 +242,6 @@ if(typeof document !== 'undefined'){
|
|||||||
exports.contentLoaded();
|
exports.contentLoaded();
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var apa = 1;
|
||||||
|
var bapselsin = 2;
|
||||||
|
|||||||
@@ -66,12 +66,14 @@ module.exports.cloneCssStyles = function(svg, classes){
|
|||||||
catch(err) {
|
catch(err) {
|
||||||
if(typeof console !== 'undefined'){
|
if(typeof console !== 'undefined'){
|
||||||
if(console.warn !== 'undefined'){
|
if(console.warn !== 'undefined'){
|
||||||
|
if(rule !== 'undefined'){
|
||||||
console.warn('Invalid CSS selector "' + rule.selectorText + '"', err);
|
console.warn('Invalid CSS selector "' + rule.selectorText + '"', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var defaultStyles = "";
|
var defaultStyles = "";
|
||||||
var embeddedStyles = "";
|
var embeddedStyles = "";
|
||||||
|
|||||||
146
test/gantt.html
146
test/gantt.html
@@ -4,12 +4,13 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
|
||||||
<script src="../dist/mermaid.full.js"></script>
|
<script src="../dist/mermaid.full.js"></script>
|
||||||
<link rel="stylesheet" href="seq.css"/>
|
<link rel="stylesheet" href="../dist/mermaid.forest.css"/>
|
||||||
<script>
|
<script>
|
||||||
var mermaid_config = {
|
var mermaid_config = {
|
||||||
startOnLoad:true
|
startOnLoad:true
|
||||||
}
|
}
|
||||||
mermaid.sequenceConfig = '{"diagramMarginX":50,"diagramMarginY":10,"actorMargin":50,"width":150,"height":45,"boxMargin":10,"boxTextMargin":5,"noteMargin":10,"messageMargin":35, "mirrorActors":false}';
|
mermaid.startOnLoad = true;
|
||||||
|
mermaid.sequenceConfig = {"diagramMarginX":50,"diagramMarginY":10,"actorMargin":50,"width":150,"height":45,"boxMargin":10,"boxTextMargin":5,"noteMargin":10,"messageMargin":35, "mirrorActors":false};
|
||||||
mermaid.ganttConfig = {
|
mermaid.ganttConfig = {
|
||||||
titleTopMargin:25,
|
titleTopMargin:25,
|
||||||
barHeight:20,
|
barHeight:20,
|
||||||
@@ -43,148 +44,9 @@
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<script>
|
|
||||||
function apa(){
|
|
||||||
console.log('CLICKED');
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
background: #fff;
|
|
||||||
font-family: 'Open-Sans',sans-serif;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .tick {
|
|
||||||
stroke: lightgrey;
|
|
||||||
opacity: 0.3;
|
|
||||||
shape-rendering: crispEdges;
|
|
||||||
}
|
|
||||||
.grid path {
|
|
||||||
stroke-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.taskText {
|
|
||||||
text-anchor:middle;
|
|
||||||
font-size:11px;
|
|
||||||
}
|
|
||||||
.taskText0, .taskText3 {
|
|
||||||
fill:black;
|
|
||||||
}
|
|
||||||
.taskText1, .taskText2 {
|
|
||||||
fill:white;
|
|
||||||
}
|
|
||||||
.taskTextOutsideRight {
|
|
||||||
fill:black;
|
|
||||||
text-anchor:start;
|
|
||||||
font-size:11px;
|
|
||||||
}
|
|
||||||
.taskTextOutsideLeft {
|
|
||||||
fill:black;
|
|
||||||
text-anchor:end;
|
|
||||||
font-size:11px;
|
|
||||||
}
|
|
||||||
.taskTextOutside0,.taskTextOutside2, {
|
|
||||||
fill:black;
|
|
||||||
}
|
|
||||||
.taskTextOutside1, .taskTextOutside3 {
|
|
||||||
fill:darkblue;
|
|
||||||
}
|
|
||||||
.titleText {
|
|
||||||
text-anchor:middle;
|
|
||||||
font-size:18px;
|
|
||||||
fill:#633;
|
|
||||||
}
|
|
||||||
.section {
|
|
||||||
stroke:none;
|
|
||||||
opacity:0.2;
|
|
||||||
}
|
|
||||||
.section0 {
|
|
||||||
fill:#6666FF;
|
|
||||||
}
|
|
||||||
.section1 {
|
|
||||||
fill:white;
|
|
||||||
opacity:0.2;
|
|
||||||
}
|
|
||||||
.section2 {
|
|
||||||
fill:orange;
|
|
||||||
opacity:0.2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.task {
|
|
||||||
/*stroke:none;*/
|
|
||||||
}
|
|
||||||
.task0 {
|
|
||||||
fill: #ffffdd;
|
|
||||||
}
|
|
||||||
.task1 {
|
|
||||||
fill: #8a90dd;
|
|
||||||
}
|
|
||||||
.task2 {
|
|
||||||
fill: #8a90dd;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sectionTitle {
|
|
||||||
text-anchor:start;
|
|
||||||
font-size:11px;
|
|
||||||
text-height:14px;
|
|
||||||
}
|
|
||||||
.sectionTitle0 { fill:#454545;}
|
|
||||||
.sectionTitle1 { fill:#454545;}
|
|
||||||
.sectionTitle2 { fill:#454545;}
|
|
||||||
.sectionTitle3 { fill:#b23473;}
|
|
||||||
.done0, .done1, .done2, .done3 {
|
|
||||||
stroke:grey;
|
|
||||||
fill: lightgrey;
|
|
||||||
stroke-width:2;
|
|
||||||
}
|
|
||||||
.crit0, .crit1, .crit2, .crit3 {
|
|
||||||
stroke:#ff8888;
|
|
||||||
fill: red;
|
|
||||||
stroke-width:2;
|
|
||||||
}
|
|
||||||
.activeCrit0, .activeCrit1, .activeCrit2, .activeCrit3 {
|
|
||||||
stroke:#ff8888;
|
|
||||||
fill: #ffffc0;
|
|
||||||
stroke-width:2;
|
|
||||||
}
|
|
||||||
.doneCrit0, .doneCrit1, .doneCrit2, .doneCrit3 {
|
|
||||||
stroke:#ff8888;
|
|
||||||
fill: lightgrey;
|
|
||||||
stroke-width:2;
|
|
||||||
cursor: pointer;
|
|
||||||
shape-rendering: crispEdges;
|
|
||||||
}
|
|
||||||
.active0 {
|
|
||||||
stroke:black;
|
|
||||||
fill: #ffffdd;
|
|
||||||
stroke-width:2;
|
|
||||||
}
|
|
||||||
.active1 {
|
|
||||||
stroke:black;
|
|
||||||
fill: #8a90dd;
|
|
||||||
stroke-width:2;
|
|
||||||
}
|
|
||||||
.active2 {
|
|
||||||
stroke:black;
|
|
||||||
fill: #8a90dd;
|
|
||||||
stroke-width:2;
|
|
||||||
}
|
|
||||||
.today {
|
|
||||||
fill:none;
|
|
||||||
stroke:red;
|
|
||||||
stroke-width:2px;
|
|
||||||
}
|
|
||||||
div.mermaid {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body style="wodth:400px;">
|
<body>
|
||||||
<h1>scale tests</h1>
|
<h1>scale tests</h1>
|
||||||
<h2>less then a day</h2>
|
<h2>less then a day</h2>
|
||||||
<div class="mermaid">
|
<div class="mermaid">
|
||||||
|
|||||||
Reference in New Issue
Block a user