Fix for issue #161 concering nested subgraphs and correct labels for each subgraph.

This commit is contained in:
knsv 2015-05-28 23:02:41 +02:00
parent cf67307711
commit b2e489b689
2 changed files with 27 additions and 34 deletions

View File

@ -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",
@ -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",

View File

@ -421,22 +421,20 @@ 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 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);
@ -445,19 +443,15 @@ exports.draw = function (text, id,isDot) {
te.attr('id', id + 'Text');
te.style('text-anchor', 'middle');
if(typeof subGraphs[graph.getDepthFirstPos(i)] === 'undefined'){
if(typeof subG.title === 'undefined'){
te.text('Undef');
}else{
//te.text(subGraphs[subGraphs.length-i-1].title);
te.text(subGraphs[pos].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'));
};