mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-15 13:29:40 +02:00
WIP - able to draw circles now.
This commit is contained in:
20199
dist/www/javascripts/lib/mermaid.js
vendored
20199
dist/www/javascripts/lib/mermaid.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,7 @@
|
|||||||
"dist-slim-mermaid": "node node_modules/browserify/bin/cmd.js src/mermaid.js -t babelify -s mermaid -o dist/mermaid.slim.js -x d3 && cat dist/mermaid.slim.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaid.slim.min.js",
|
"dist-slim-mermaid": "node node_modules/browserify/bin/cmd.js src/mermaid.js -t babelify -s mermaid -o dist/mermaid.slim.js -x d3 && cat dist/mermaid.slim.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaid.slim.min.js",
|
||||||
"dist-slim-mermaidAPI": "node node_modules/browserify/bin/cmd.js src/mermaidAPI.js -t babelify -s mermaidAPI -o dist/mermaidAPI.slim.js -x d3 && cat dist/mermaidAPI.slim.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaidAPI.slim.min.js",
|
"dist-slim-mermaidAPI": "node node_modules/browserify/bin/cmd.js src/mermaidAPI.js -t babelify -s mermaidAPI -o dist/mermaidAPI.slim.js -x d3 && cat dist/mermaidAPI.slim.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaidAPI.slim.min.js",
|
||||||
"dist-mermaid": "node node_modules/browserify/bin/cmd.js src/mermaid.js -t babelify -s mermaid -o dist/mermaid.js && cat dist/mermaid.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaid.min.js",
|
"dist-mermaid": "node node_modules/browserify/bin/cmd.js src/mermaid.js -t babelify -s mermaid -o dist/mermaid.js && cat dist/mermaid.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaid.min.js",
|
||||||
"dist-mermaid-nomin": "node node_modules/browserify/bin/cmd.js src/mermaid.js -t babelify -s mermaid -o dist/mermaid.js && node bin/mermaid -v -p testgitgraph.mm && testgitgraph.mm.png",
|
"dist-mermaid-nomin": "node node_modules/browserify/bin/cmd.js src/mermaid.js -t babelify -s mermaid -o dist/mermaid.js && node bin/mermaid -v -s testgitgraph.mm && testgitgraph.mm.svg",
|
||||||
"dist-mermaidAPI": "node node_modules/browserify/bin/cmd.js src/mermaidAPI.js -t babelify -s mermaidAPI -o dist/mermaidAPI.js && cat dist/mermaidAPI.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaidAPI.min.js",
|
"dist-mermaidAPI": "node node_modules/browserify/bin/cmd.js src/mermaidAPI.js -t babelify -s mermaidAPI -o dist/mermaidAPI.js && cat dist/mermaidAPI.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaidAPI.min.js",
|
||||||
"dist": "npm run dist-slim-mermaid && npm run dist-slim-mermaidAPI && npm run dist-mermaid && npm run dist-mermaidAPI"
|
"dist": "npm run dist-slim-mermaid && npm run dist-slim-mermaidAPI && npm run dist-mermaid && npm run dist-mermaidAPI"
|
||||||
},
|
},
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
var crypto = require("crypto");
|
|
||||||
var Logger = require('../../logger');
|
var Logger = require('../../logger');
|
||||||
var _ = require("lodash");
|
var _ = require("lodash");
|
||||||
|
|
||||||
var log = new Logger.Log();
|
//var log = new Logger.Log();
|
||||||
//var log = new Logger.Log(1);
|
var log = new Logger.Log(1);
|
||||||
|
|
||||||
|
|
||||||
var commits = {};
|
var commits = {};
|
||||||
@@ -12,9 +11,16 @@ var branches = { "master" : head };
|
|||||||
var curBranch = "master";
|
var curBranch = "master";
|
||||||
var direction = "LR";
|
var direction = "LR";
|
||||||
var seq = 0;
|
var seq = 0;
|
||||||
|
function getRandomInt(min, max) {
|
||||||
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
|
}
|
||||||
function getId() {
|
function getId() {
|
||||||
return crypto.randomBytes(20).toString('hex').substring(0, 7);
|
var pool="0123456789abcdef";
|
||||||
|
var id = "";
|
||||||
|
for (var i = 0; i < 7; i++) {
|
||||||
|
id += pool[getRandomInt(0,16)]
|
||||||
|
}
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -54,7 +60,7 @@ exports.commit = function(msg) {
|
|||||||
head = commit;
|
head = commit;
|
||||||
commits[commit.id] = commit;
|
commits[commit.id] = commit;
|
||||||
branches[curBranch] = commit.id;
|
branches[curBranch] = commit.id;
|
||||||
log.debug("in pushCommit");
|
log.debug("in pushCommit '" + commit.id + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.branch = function(name) {
|
exports.branch = function(name) {
|
||||||
@@ -143,12 +149,8 @@ function prettyPrintCommitHistory(commitArr) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
exports.prettyPrint = function() {
|
exports.prettyPrint = function() {
|
||||||
var commitArr = Object.keys(commits).map(function (key) {
|
log.debug(commits);
|
||||||
return commits[key];
|
var node = exports.getCommitsArray()[0];
|
||||||
});
|
|
||||||
var sortedCommits = _.orderBy(commitArr, ['seq'], ['desc']);
|
|
||||||
console.log(sortedCommits);
|
|
||||||
var node = sortedCommits[0];
|
|
||||||
prettyPrintCommitHistory([node]);
|
prettyPrintCommitHistory([node]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,9 +161,20 @@ exports.clear = function () {
|
|||||||
curBranch = "master";
|
curBranch = "master";
|
||||||
seq =0;
|
seq =0;
|
||||||
}
|
}
|
||||||
|
exports.getBranchesAsObjArray = function() {
|
||||||
|
return _.map(branches, function(v,k) {
|
||||||
|
return {"name": k, "commitid": v};
|
||||||
|
});
|
||||||
|
}
|
||||||
exports.getBranches = function() { return branches; }
|
exports.getBranches = function() { return branches; }
|
||||||
exports.getCommits = function() { return commits; }
|
exports.getCommits = function() { return commits; }
|
||||||
|
exports.getCommitsArray = function() {
|
||||||
|
var commitArr = Object.keys(commits).map(function (key) {
|
||||||
|
return commits[key];
|
||||||
|
});
|
||||||
|
_.each(commitArr, function(o) { console.log(o.id) });
|
||||||
|
return _.orderBy(commitArr, ['seq'], ['desc']);
|
||||||
|
}
|
||||||
exports.getCurrentBranch = function() { return curBranch; }
|
exports.getCurrentBranch = function() { return curBranch; }
|
||||||
exports.getDirection = function() { return direction; }
|
exports.getDirection = function() { return direction; }
|
||||||
exports.getHead = function() { return head; }
|
exports.getHead = function() { return head; }
|
||||||
|
@@ -17,22 +17,37 @@ exports.draw = function (txt, id, ver) {
|
|||||||
|
|
||||||
log.debug('in gitgraph renderer', txt, id, ver);
|
log.debug('in gitgraph renderer', txt, id, ver);
|
||||||
// Parse the graph definition
|
// Parse the graph definition
|
||||||
//log.debug(parser, db);
|
|
||||||
parser.parse(txt + "\n");
|
parser.parse(txt + "\n");
|
||||||
|
var commits = db.getCommitsArray();
|
||||||
|
log.debug(commits);
|
||||||
|
log.debug("id: " + commits[0].id);
|
||||||
|
log.debug(db.getCommits());
|
||||||
|
log.debug("length:", commits.length);
|
||||||
|
log.debug("length:", Object.keys(db.getCommits()).length);
|
||||||
// Fetch the default direction, use TD if none was found
|
// Fetch the default direction, use TD if none was found
|
||||||
var svg = d3.select('#'+id);
|
var svg = d3.select('#'+id);
|
||||||
|
|
||||||
var g = svg.append('g');
|
var g = svg.append('g');
|
||||||
|
|
||||||
g.append('text') // text label for the x axis
|
//g.append('text') // text label for the x axis
|
||||||
.attr('x', 100)
|
//.attr('x', 100)
|
||||||
.attr('y', 40)
|
//.attr('y', 40)
|
||||||
.attr('class','version')
|
//.attr('class','version')
|
||||||
.attr('font-size','32px')
|
//.attr('font-size','32px')
|
||||||
.style('text-anchor', 'middle')
|
//.style('text-anchor', 'middle')
|
||||||
.text('mermaid raghu'+ ver);
|
//.text('mermaid raghu'+ ver);
|
||||||
|
|
||||||
|
var circles = svg.selectAll("circle")
|
||||||
|
.data(commits)
|
||||||
|
.enter()
|
||||||
|
.append("circle")
|
||||||
|
.attr("cx", function(d, i){
|
||||||
|
return (i*50) + 25;
|
||||||
|
})
|
||||||
|
.attr("cy", 50)
|
||||||
|
.attr("r", 15)
|
||||||
|
.attr("fill", "yellow")
|
||||||
|
.attr("stroke", "grey");
|
||||||
/*
|
/*
|
||||||
var box = exports.bounds.getBounds();
|
var box = exports.bounds.getBounds();
|
||||||
|
|
||||||
|
@@ -69,7 +69,10 @@ function Log(level) {
|
|||||||
if (typeof console.log !== 'undefined') { //eslint-disable-line no-console
|
if (typeof console.log !== 'undefined') { //eslint-disable-line no-console
|
||||||
//return console.log('[' + formatTime(new Date()) + '] ' , str); //eslint-disable-line no-console
|
//return console.log('[' + formatTime(new Date()) + '] ' , str); //eslint-disable-line no-console
|
||||||
args.unshift('[' + formatTime(new Date()) + '] ');
|
args.unshift('[' + formatTime(new Date()) + '] ');
|
||||||
console.log.apply(console, args);
|
console.log.apply(console, args.map(function(a){
|
||||||
|
if (typeof a === "object") return JSON.stringify(a, null, 2);
|
||||||
|
return a;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user