Skip to content

Commit

Permalink
Fix for issue #161 concering nested subgraphs and correct labels for …
Browse files Browse the repository at this point in the history
…each subgraph.
  • Loading branch information
knsv committed May 28, 2015
1 parent cf67307 commit b2e489b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 38 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"dependencies": {
"chalk": "^0.5.1",
"d3": "~3.4.13",
"dagre-d3": "~0.4.2",
"dagre-d3": "~0.4.8",
"he": "^0.5.0",
"minimist": "^1.1.0",
"mkdirp": "^0.5.0",
Expand All @@ -39,7 +39,6 @@
"clone": "^0.2.0",
"codeclimate-test-reporter": "0.0.4",
"d3": "~3.4.13",
"dagre-d3": "~0.3.3",
"dateformat": "^1.0.11",
"event-stream": "^3.2.0",
"foundation": "^4.2.1-1",
Expand Down
66 changes: 30 additions & 36 deletions src/diagrams/flowchart/flowRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,43 +421,37 @@ exports.draw = function (text, id,isDot) {
// Index nodes
graph.indexNodes('sunGraph'+i);

setTimeout(function(){
var i = 0;
//subGraphs.forEach(function(subG) {
for(i=0;i<subGraphs.length;i++){
var pos = graph.getDepthFirstPos(i);
subG = subGraphs[i];

var clusterRects = document.querySelectorAll('#' + id + ' .clusters rect');
var clusters = document.querySelectorAll('#' + id + ' .cluster');


if (subG.title !== 'undefined') {
var xPos = clusterRects[i].x.baseVal.value;
var yPos = clusterRects[i].y.baseVal.value;
var width = clusterRects[i].width.baseVal.value;
var cluster = d3.select(clusters[i]);
var te = cluster.append('text');
te.attr('x', xPos + width / 2);
te.attr('y', yPos + 14);
te.attr('fill', 'black');
te.attr('stroke', 'none');
te.attr('id', id + 'Text');
te.style('text-anchor', 'middle');

if(typeof subGraphs[graph.getDepthFirstPos(i)] === 'undefined'){
te.text('Undef');
}else{
//te.text(subGraphs[subGraphs.length-i-1].title);
te.text(subGraphs[pos].title);

console.log('Setting subg - '+i+' to title '+subGraphs[pos].title);
}
var i = 0;
for(i=0;i<subGraphs.length;i++){
var pos = graph.getDepthFirstPos(i);
subG = subGraphs[i];

if (subG.title !== 'undefined') {
var clusterRects = document.querySelectorAll('#' + id + ' #' + subG.id + ' rect');
//console.log('looking up: #' + id + ' #' + subG.id)
var clusterEl = document.querySelectorAll('#' + id + ' #' + subG.id);

var xPos = clusterRects[0].x.baseVal.value;
var yPos = clusterRects[0].y.baseVal.value;
var width = clusterRects[0].width.baseVal.value;
var cluster = d3.select(clusterEl[0]);
var te = cluster.append('text');
te.attr('x', xPos + width / 2);
te.attr('y', yPos + 14);
te.attr('fill', 'black');
te.attr('stroke', 'none');
te.attr('id', id + 'Text');
te.style('text-anchor', 'middle');

if(typeof subG.title === 'undefined'){
te.text('Undef');
}else{
//te.text(subGraphs[subGraphs.length-i-1].title);
te.text(subG.title);

console.log('Setting subg - '+i+' to title '+subGraphs[pos].title);
}
}
// i = i + 1;
//});
},20);
//console.log('GTPOD:'+graph.getDepthFirstPos('subGraph0'));
}
};

0 comments on commit b2e489b

Please sign in to comment.