much better positions
This commit is contained in:
parent
0bdc79aff2
commit
3fff821e28
1 changed files with 28 additions and 7 deletions
|
@ -1041,7 +1041,7 @@ class Graph {
|
||||||
.force( "link", d3.forceLink( this.directions ).id( d => d['@id'] ).strength(0) )
|
.force( "link", d3.forceLink( this.directions ).id( d => d['@id'] ).strength(0) )
|
||||||
// .force( "charge", d3.forceManyBody().strength( 100 ) )
|
// .force( "charge", d3.forceManyBody().strength( 100 ) )
|
||||||
// .force( "center", d3.forceCenter( this.width / 2, this.height / 2 ) )
|
// .force( "center", d3.forceCenter( this.width / 2, this.height / 2 ) )
|
||||||
.force( "collide", d3.forceCollide( this.nodeSize * 1.5 ).strength(1) )
|
.force( "collide", d3.forceCollide( this.nodeSize * 1.5 ).strength(3) )
|
||||||
.force( "forceX", d3.forceX(function(m){
|
.force( "forceX", d3.forceX(function(m){
|
||||||
let fx = panopticon.graph.distances[m['@id']] !== null ? panopticon.graph.distances[m['@id']][0] * panopticon.graph.nodeSize * 4 : 0
|
let fx = panopticon.graph.distances[m['@id']] !== null ? panopticon.graph.distances[m['@id']][0] * panopticon.graph.nodeSize * 4 : 0
|
||||||
// console.log('fx', m['@id'], panopticon.graph.distances[m['@id']], fx);
|
// console.log('fx', m['@id'], panopticon.graph.distances[m['@id']], fx);
|
||||||
|
@ -1263,18 +1263,34 @@ class Graph {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let i = 0;
|
let i = 0, y =0;
|
||||||
for(let childMsgId of msgsPerMsg[msgId]) {
|
for(let childMsgId of msgsPerMsg[msgId]) {
|
||||||
if(distances[childMsgId] === null || (goingDown && distances[childMsgId][0] > depth)) {
|
if(distances[childMsgId] === null || (goingDown && distances[childMsgId][0] > depth)) {
|
||||||
if(i > 0)
|
|
||||||
yPos++;
|
|
||||||
i++;
|
|
||||||
|
|
||||||
distances[childMsgId] = [depth, yPos];
|
if(distances[childMsgId] === null) {
|
||||||
|
if(i > 0){
|
||||||
|
yPos++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
|
||||||
|
console.log('set for id', childMsgId, goingDown, depth, yPos);
|
||||||
|
distances[childMsgId] = [depth, yPos];
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
y++;
|
||||||
|
}
|
||||||
// console.log(goingDown, childMsgId, depth);
|
// console.log(goingDown, childMsgId, depth);
|
||||||
yPos = traverseMsg(childMsgId, goingDown ? (depth+1) : (depth - 1), goingDown, yPos);
|
yPos = traverseMsg(childMsgId, goingDown ? (depth+1) : (depth - 1), goingDown, yPos);
|
||||||
}
|
}
|
||||||
else if(!goingDown && distances[childMsgId][0] < depth) {
|
else if(!goingDown && distances[childMsgId][0] < depth) {
|
||||||
|
if(childMsgId == 'en-njsgkr4az') {
|
||||||
|
console.log('set for id', childMsgId, goingDown);
|
||||||
|
}
|
||||||
|
if(distances[childMsgId] === null) {
|
||||||
|
distances[childMsgId] = [depth, yPos];
|
||||||
|
}
|
||||||
|
|
||||||
// console.log('a', depth);
|
// console.log('a', depth);
|
||||||
yPos = traverseMsg(childMsgId, depth - 1, goingDown, yPos);
|
yPos = traverseMsg(childMsgId, depth - 1, goingDown, yPos);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1282,7 +1298,12 @@ class Graph {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if( i == 0 && y == 1) {
|
||||||
|
// // we reached an item that branches back into the tree
|
||||||
|
// return yPos -1;
|
||||||
|
// }
|
||||||
|
// console.log('yPos',msgId,yPos);
|
||||||
return yPos;
|
return yPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue