Browse Source

hunting bug...

css_transitions
Alex de Mulder 11 years ago
parent
commit
9c1e96a492
5 changed files with 42 additions and 21 deletions
  1. +20
    -10
      dist/vis.js
  2. +2
    -1
      examples/graph/02_random_nodes.html
  3. +4
    -3
      src/graph/ClusterMixin.js
  4. +2
    -1
      src/graph/Graph.js
  5. +14
    -6
      src/graph/physicsMixin.js

+ 20
- 10
dist/vis.js View File

@ -10953,7 +10953,7 @@ var physicsMixin = {
*
* @private
*/
_initializeForceCalculation : function() {
_initializeForceCalculation : function(useBarnesHut) {
// stop calculation if there is only one node
if (this.nodeIndices.length == 1) {
this.nodes[this.nodeIndices[0]]._setForce(0,0);
@ -10964,9 +10964,15 @@ var physicsMixin = {
this.clusterToFit(this.constants.clustering.reduceToNodes, false);
}
// we now start the force calculation
this._calculateForcesBarnesHut();
// this._calculateForcesRepulsion();
this._calculateForcesRepulsion();
// // we now start the force calculation
// if (useBarnesHut == true) {
// this._calculateForcesBarnesHut();
// }
// else {
// this._calculateForcesRepulsion();
// }
}
},
@ -11142,7 +11148,7 @@ var physicsMixin = {
fx = Math.cos(angle) * springForce;
fy = Math.sin(angle) * springForce;
//console.log(edge.length,dx,dy,edge.springConstant,angle)
edge.from._addForce(-fx, -fy);
edge.to._addForce(fx, fy);
}
@ -11251,6 +11257,7 @@ var physicsMixin = {
range:{minX:minX,maxX:maxX,minY:minY,maxY:maxY},
size: Math.abs(maxX - minX),
children: {data:null},
level: 0,
childrenCount: 4
}};
this._splitBranch(barnesHutTree.root);
@ -11265,7 +11272,6 @@ var physicsMixin = {
this.barnesHutTree = barnesHutTree
},
_updateBranchMass : function(parentBranch, node) {
var totalMass = parentBranch.mass + node.mass;
var totalMassInv = 1/totalMass;
@ -11377,12 +11383,14 @@ var physicsMixin = {
break;
}
parentBranch.children[region] = {
CenterOfMass:{x:0,y:0},
mass:0,
range:{minX:minX,maxX:maxX,minY:minY,maxY:maxY},
size: 0.5 * parentBranch.size,
children: {data:null},
level: parentBranch.level +1,
childrenCount: 0
};
},
@ -12763,6 +12771,7 @@ var ClusterMixin = {
}
}
}
},
/**
@ -12808,9 +12817,9 @@ var ClusterMixin = {
parentNode.dynamicEdgesLength = parentNode.dynamicEdges.length;
// place the child node near the parent, not at the exact same location to avoid chaos in the system
childNode.x = parentNode.x + this.constants.edges.length * (0.1 + 0.3 * (0.5 - Math.random()) * parentNode.clusterSize);
childNode.y = parentNode.y + this.constants.edges.length * (0.1 + 0.3 * (0.5 - Math.random()) * parentNode.clusterSize);
childNode.x = parentNode.x + this.constants.physics.springLength * (0.1 * (0.5 - Math.random()) * parentNode.clusterSize);
childNode.y = parentNode.y + this.constants.physics.springLength * (0.1 * (0.5 - Math.random()) * parentNode.clusterSize);
console.log(childNode.x,childNode.y,parentNode.x,parentNode.y);
// remove node from the list
delete parentNode.containedNodes[containedNodeId];
@ -16135,6 +16144,7 @@ Graph.prototype.start = function() {
graph._zoom(graph.scale*(1 + graph.zoomIncrement), center);
}
graph.start();
graph.start();
graph._redraw();
@ -16157,7 +16167,7 @@ Graph.prototype.start = function() {
*/
Graph.prototype.singleStep = function() {
if (this.moving) {
this._initializeForceCalculation();
this._initializeForceCalculation(true);
this._discreteStepNodes();
var vmin = this.constants.minVelocity;

+ 2
- 1
examples/graph/02_random_nodes.html View File

@ -90,7 +90,8 @@
edges: {
length: 50
},
stabilize: false
stabilize: false,
clustering : true
};
graph = new vis.Graph(container, data, options);

+ 4
- 3
src/graph/ClusterMixin.js View File

@ -313,6 +313,7 @@ var ClusterMixin = {
}
}
}
},
/**
@ -358,9 +359,9 @@ var ClusterMixin = {
parentNode.dynamicEdgesLength = parentNode.dynamicEdges.length;
// place the child node near the parent, not at the exact same location to avoid chaos in the system
childNode.x = parentNode.x + this.constants.edges.length * (0.1 + 0.3 * (0.5 - Math.random()) * parentNode.clusterSize);
childNode.y = parentNode.y + this.constants.edges.length * (0.1 + 0.3 * (0.5 - Math.random()) * parentNode.clusterSize);
childNode.x = parentNode.x + this.constants.physics.springLength * (0.1 * (0.5 - Math.random()) * parentNode.clusterSize);
childNode.y = parentNode.y + this.constants.physics.springLength * (0.1 * (0.5 - Math.random()) * parentNode.clusterSize);
console.log(childNode.x,childNode.y,parentNode.x,parentNode.y);
// remove node from the list
delete parentNode.containedNodes[containedNodeId];

+ 2
- 1
src/graph/Graph.js View File

@ -1769,6 +1769,7 @@ Graph.prototype.start = function() {
graph._zoom(graph.scale*(1 + graph.zoomIncrement), center);
}
graph.start();
graph.start();
graph._redraw();
@ -1791,7 +1792,7 @@ Graph.prototype.start = function() {
*/
Graph.prototype.singleStep = function() {
if (this.moving) {
this._initializeForceCalculation();
this._initializeForceCalculation(true);
this._discreteStepNodes();
var vmin = this.constants.minVelocity;

+ 14
- 6
src/graph/physicsMixin.js View File

@ -11,7 +11,7 @@ var physicsMixin = {
*
* @private
*/
_initializeForceCalculation : function() {
_initializeForceCalculation : function(useBarnesHut) {
// stop calculation if there is only one node
if (this.nodeIndices.length == 1) {
this.nodes[this.nodeIndices[0]]._setForce(0,0);
@ -22,9 +22,15 @@ var physicsMixin = {
this.clusterToFit(this.constants.clustering.reduceToNodes, false);
}
// we now start the force calculation
this._calculateForcesBarnesHut();
// this._calculateForcesRepulsion();
this._calculateForcesRepulsion();
// // we now start the force calculation
// if (useBarnesHut == true) {
// this._calculateForcesBarnesHut();
// }
// else {
// this._calculateForcesRepulsion();
// }
}
},
@ -200,7 +206,7 @@ var physicsMixin = {
fx = Math.cos(angle) * springForce;
fy = Math.sin(angle) * springForce;
//console.log(edge.length,dx,dy,edge.springConstant,angle)
edge.from._addForce(-fx, -fy);
edge.to._addForce(fx, fy);
}
@ -309,6 +315,7 @@ var physicsMixin = {
range:{minX:minX,maxX:maxX,minY:minY,maxY:maxY},
size: Math.abs(maxX - minX),
children: {data:null},
level: 0,
childrenCount: 4
}};
this._splitBranch(barnesHutTree.root);
@ -323,7 +330,6 @@ var physicsMixin = {
this.barnesHutTree = barnesHutTree
},
_updateBranchMass : function(parentBranch, node) {
var totalMass = parentBranch.mass + node.mass;
var totalMassInv = 1/totalMass;
@ -435,12 +441,14 @@ var physicsMixin = {
break;
}
parentBranch.children[region] = {
CenterOfMass:{x:0,y:0},
mass:0,
range:{minX:minX,maxX:maxX,minY:minY,maxY:maxY},
size: 0.5 * parentBranch.size,
children: {data:null},
level: parentBranch.level +1,
childrenCount: 0
};
},

Loading…
Cancel
Save