mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08: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:
commit
9face45357
@ -383,5 +383,4 @@
|
||||
## [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)*
|
1
dist/mermaid.forest.css
vendored
1
dist/mermaid.forest.css
vendored
@ -4,6 +4,7 @@
|
||||
.mermaid .label {
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.node rect,
|
||||
.node circle,
|
||||
.node polygon {
|
||||
|
10
lib/cli.js
10
lib/cli.js
@ -24,6 +24,7 @@ function cli(options) {
|
||||
, verbose: 'v'
|
||||
, phantomPath: 'e'
|
||||
, sequenceConfig: 'c'
|
||||
, ganttConfig: 'g'
|
||||
, css: 't'
|
||||
}
|
||||
, 'boolean': ['help', 'png', 'svg']
|
||||
@ -45,6 +46,7 @@ function cli(options) {
|
||||
, " -e --phantomPath Specify the path to the phantomjs executable"
|
||||
, " -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"
|
||||
, " -g --ganttConfig Specify the path to the file with the configuration to be applied in the gantt diagram"
|
||||
, " -h --help Show this message"
|
||||
, " -v --verbose Show logging"
|
||||
, " --version Print version and quit"
|
||||
@ -74,7 +76,7 @@ cli.prototype.parse = function(argv, next) {
|
||||
}
|
||||
|
||||
// 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] !== 'string' || options[i].length < 1) {
|
||||
this.errors.push(new Error(i + " expects a value."))
|
||||
@ -94,6 +96,12 @@ cli.prototype.parse = function(argv, next) {
|
||||
options.sequenceConfig = checkConfig(options.sequenceConfig)
|
||||
}
|
||||
|
||||
|
||||
if (options.ganttConfig) {
|
||||
options.ganttConfig = checkConfig(options.ganttConfig)
|
||||
console.log('Got conf'+options.ganttConfig);
|
||||
}
|
||||
|
||||
if (options.css) {
|
||||
try {
|
||||
options.css = fs.readFileSync(options.css, 'utf8')
|
||||
|
@ -20,6 +20,7 @@ function processMermaid(files, _options, _next) {
|
||||
, options.svg
|
||||
, options.css || ''
|
||||
, options.sequenceConfig
|
||||
, options.ganttConfig
|
||||
, options.verbose
|
||||
]
|
||||
|
||||
|
@ -28,18 +28,24 @@ var system = require('system')
|
||||
, fs = require('fs')
|
||||
, webpage = require('webpage')
|
||||
|
||||
|
||||
var page = webpage.create()
|
||||
, files = phantom.args.slice(6, phantom.args.length)
|
||||
, files = phantom.args.slice(7, phantom.args.length)
|
||||
, options = {
|
||||
outputDir: phantom.args[0]
|
||||
, png: phantom.args[1] === 'true' ? true : false
|
||||
, svg: phantom.args[2] === 'true' ? true : false
|
||||
, css: phantom.args[3] !== '' ? phantom.args[3] : '* { margin: 0; padding: 0; }'
|
||||
, 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)
|
||||
|
||||
|
||||
console.log('options');
|
||||
console.log(options.ganttConfig);
|
||||
|
||||
page.content = [
|
||||
'<html>'
|
||||
, '<head>'
|
||||
@ -68,8 +74,9 @@ files.forEach(function(file) {
|
||||
// look like it. we need to serialize then unserialize the svgContent that's
|
||||
// taken from the DOM
|
||||
svgContent = page.evaluate(executeInPage, {
|
||||
contents: contents,
|
||||
sequenceConfig: options.sequenceConfig
|
||||
contents : contents,
|
||||
ganttConfig : options.ganttConfig,
|
||||
sequenceConfig : options.sequenceConfig
|
||||
})
|
||||
oDOM = oParser.parseFromString(svgContent, "text/xml")
|
||||
|
||||
@ -193,6 +200,7 @@ function executeInPage(data) {
|
||||
var xmlSerializer = new XMLSerializer()
|
||||
, contents = data.contents
|
||||
, sequenceConfig = data.sequenceConfig
|
||||
, ganttConfig = data.ganttConfig
|
||||
, toRemove
|
||||
, el
|
||||
, elContent
|
||||
@ -221,6 +229,17 @@ function executeInPage(data) {
|
||||
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();
|
||||
|
||||
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;
|
||||
|
||||
elem.style.height = h + 'px';
|
||||
elem.height = h;
|
||||
elem.setAttribute('height', h);
|
||||
var svg = d3.select('#' + id);
|
||||
|
||||
// http://codepen.io/anon/pen/azLvWR
|
||||
|
@ -1,10 +1,11 @@
|
||||
/**
|
||||
* Created by knut on 14-11-19.
|
||||
*/
|
||||
var actors = {};
|
||||
var actors = {};
|
||||
var actorKeys = [];
|
||||
var messages = [];
|
||||
var notes = [];
|
||||
var messages = [];
|
||||
var notes = [];
|
||||
|
||||
exports.addActor = function(id,name,description){
|
||||
//console.log('Adding actor: '+id);
|
||||
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});
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
exports.addSignal = function(idFrom, idTo, message, messageType){
|
||||
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
|
||||
messages.push({from:idFrom, to:idTo, message:message, type:messageType});
|
||||
@ -36,37 +40,36 @@ exports.getActorKeys = function(){
|
||||
};
|
||||
|
||||
exports.clear = function(){
|
||||
actors = {};
|
||||
actors = {};
|
||||
messages = [];
|
||||
};
|
||||
|
||||
exports.LINETYPE = {
|
||||
SOLID : 0,
|
||||
DOTTED : 1,
|
||||
NOTE : 2,
|
||||
SOLID_CROSS : 3,
|
||||
DOTTED_CROSS: 4,
|
||||
SOLID_OPEN : 5,
|
||||
DOTTED_OPEN : 6,
|
||||
LOOP_START : 10,
|
||||
LOOP_END : 11,
|
||||
ALT_START : 12,
|
||||
ALT_ELSE : 13,
|
||||
ALT_END : 14,
|
||||
OPT_START : 15,
|
||||
OPT_END : 16
|
||||
|
||||
SOLID : 0 ,
|
||||
DOTTED : 1 ,
|
||||
NOTE : 2 ,
|
||||
SOLID_CROSS : 3 ,
|
||||
DOTTED_CROSS : 4 ,
|
||||
SOLID_OPEN : 5 ,
|
||||
DOTTED_OPEN : 6 ,
|
||||
LOOP_START : 10 ,
|
||||
LOOP_END : 11 ,
|
||||
ALT_START : 12 ,
|
||||
ALT_ELSE : 13 ,
|
||||
ALT_END : 14 ,
|
||||
OPT_START : 15 ,
|
||||
OPT_END : 16
|
||||
};
|
||||
|
||||
exports.ARROWTYPE = {
|
||||
FILLED : 0,
|
||||
OPEN : 1
|
||||
FILLED : 0,
|
||||
OPEN : 1
|
||||
};
|
||||
|
||||
exports.PLACEMENT = {
|
||||
LEFTOF : 0,
|
||||
RIGHTOF : 1,
|
||||
OVER : 2
|
||||
LEFTOF : 0,
|
||||
RIGHTOF : 1,
|
||||
OVER : 2
|
||||
};
|
||||
|
||||
exports.addNote = function (actor, placement, message){
|
||||
|
@ -217,15 +217,15 @@ exports.getTextObj = function(){
|
||||
|
||||
exports.getNoteRect = function(){
|
||||
var rect = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
fill: '#EDF2AE',
|
||||
stroke: '#666',
|
||||
width: 100,
|
||||
anchor:'start',
|
||||
height: 100,
|
||||
rx: 0,
|
||||
ry: 0
|
||||
x : 0,
|
||||
y : 0,
|
||||
fill : '#EDF2AE',
|
||||
stroke : '#666',
|
||||
width : 100,
|
||||
anchor : 'start',
|
||||
height : 100,
|
||||
rx : 0,
|
||||
ry : 0
|
||||
};
|
||||
return rect;
|
||||
};
|
||||
|
22
src/main.js
22
src/main.js
@ -186,21 +186,22 @@ var equals = function (val, variable){
|
||||
};
|
||||
|
||||
global.mermaid = {
|
||||
startOnLoad:true,
|
||||
htmlLabels:true,
|
||||
init:function(sequenceConfig, nodes){
|
||||
startOnLoad: true,
|
||||
htmlLabels: true,
|
||||
|
||||
init: function(sequenceConfig, nodes) {
|
||||
init.apply(null, arguments);
|
||||
},
|
||||
version:function(){
|
||||
version: function() {
|
||||
return exports.version();
|
||||
},
|
||||
getParser:function(){
|
||||
getParser: function() {
|
||||
return flow.parser;
|
||||
},
|
||||
parse:function(text){
|
||||
parse: function(text) {
|
||||
return parse(text);
|
||||
},
|
||||
parseError:function(err,hash){
|
||||
parseError: function(err, hash) {
|
||||
console.log('Mermaid Syntax error:');
|
||||
console.log(err);
|
||||
}
|
||||
@ -222,12 +223,12 @@ exports.contentLoaded = function(){
|
||||
if (typeof mermaid_config !== 'undefined') {
|
||||
// Check if property startOnLoad is set
|
||||
if (equals(true, mermaid_config.startOnLoad)) {
|
||||
global.mermaid.init(mermaid.sequenceConfig);
|
||||
global.mermaid.init();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 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();
|
||||
}, false);
|
||||
}
|
||||
|
||||
var apa = 1;
|
||||
var bapselsin = 2;
|
||||
|
@ -66,7 +66,9 @@ module.exports.cloneCssStyles = function(svg, classes){
|
||||
catch(err) {
|
||||
if(typeof console !== 'undefined'){
|
||||
if(console.warn !== 'undefined'){
|
||||
console.warn('Invalid CSS selector "' + rule.selectorText + '"', err);
|
||||
if(rule !== 'undefined'){
|
||||
console.warn('Invalid CSS selector "' + rule.selectorText + '"', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
148
test/gantt.html
148
test/gantt.html
@ -4,12 +4,13 @@
|
||||
<meta charset="UTF-8">
|
||||
|
||||
<script src="../dist/mermaid.full.js"></script>
|
||||
<link rel="stylesheet" href="seq.css"/>
|
||||
<link rel="stylesheet" href="../dist/mermaid.forest.css"/>
|
||||
<script>
|
||||
var mermaid_config = {
|
||||
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 = {
|
||||
titleTopMargin:25,
|
||||
barHeight:20,
|
||||
@ -43,148 +44,9 @@
|
||||
]
|
||||
};
|
||||
</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>
|
||||
<body style="wodth:400px;">
|
||||
<body>
|
||||
<h1>scale tests</h1>
|
||||
<h2>less then a day</h2>
|
||||
<div class="mermaid">
|
||||
|
Loading…
x
Reference in New Issue
Block a user