mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-23 09:20:03 +02:00
Introducing subgraphs
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
var vertices = {};
|
||||
var edges = [];
|
||||
var classes = [];
|
||||
var subGraphs = [];
|
||||
var direction;
|
||||
// Functions to be run after graph rendering
|
||||
var funs = [];
|
||||
@@ -197,6 +198,7 @@ exports.clear = function () {
|
||||
classes = {};
|
||||
edges = [];
|
||||
funs = [];
|
||||
subGraphs = [];
|
||||
};
|
||||
/**
|
||||
*
|
||||
@@ -205,3 +207,29 @@ exports.clear = function () {
|
||||
exports.defaultStyle = function () {
|
||||
return "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;";
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears the internal graph db so that a new graph can be parsed.
|
||||
*/
|
||||
exports.addSubGraph = function (list) {
|
||||
function uniq(a) {
|
||||
var prims = {"boolean":{}, "number":{}, "string":{}}, objs = [];
|
||||
|
||||
return a.filter(function(item) {
|
||||
var type = typeof item;
|
||||
if(type in prims)
|
||||
return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true);
|
||||
else
|
||||
return objs.indexOf(item) >= 0 ? false : objs.push(item);
|
||||
});
|
||||
}
|
||||
|
||||
var subG = [];
|
||||
|
||||
subG = uniq(subG.concat.apply(subG,list));
|
||||
|
||||
subGraphs.push(subG);
|
||||
};
|
||||
exports.getSubGraphs = function (list) {
|
||||
return subGraphs;
|
||||
};
|
||||
|
Reference in New Issue
Block a user