Browse Source

Merge remote-tracking branch 'origin/develop' into develop

Conflicts:
	dist/vis.js
v3_develop
jos 10 years ago
parent
commit
3a08f8be79
7 changed files with 10103 additions and 35 deletions
  1. +1
    -1
      examples/network/27_world_cup_network.html
  2. +10053
    -0
      examples/network/28_world_cup_network_performance.html
  3. +1
    -0
      examples/network/index.html
  4. +33
    -28
      lib/network/Edge.js
  5. +13
    -4
      lib/network/Network.js
  6. +1
    -1
      lib/network/Node.js
  7. +1
    -1
      lib/network/mixins/physics/PhysicsMixin.js

+ 1
- 1
examples/network/27_world_cup_network.html View File

@ -47,7 +47,7 @@ inheritColor option:
<option value="to">to</option> <option value="to">to</option>
<option value="false">false</option> <option value="false">false</option>
</select><br/> </select><br/>
Roundness (0..1): <input type="range" min="0" max="1" value="0.5" step="0.05" style="width:200px" id="roundnessSlider"> <input id="roundnessScreen" value="0.5">
Roundness (0..1): <input type="range" min="0" max="1" value="0.5" step="0.05" style="width:200px" id="roundnessSlider"> <input id="roundnessScreen" value="0.5"> (0.5 is max roundness for continuous, 1.0 for the others)
<br /> <br />
Hide edges on drag: <input type="checkbox" checked="checked" id="hideEdgesOnDrag"><br/> Hide edges on drag: <input type="checkbox" checked="checked" id="hideEdgesOnDrag"><br/>
Hide nodes on drag: <input type="checkbox" id="hideNodesOnDrag"> Hide nodes on drag: <input type="checkbox" id="hideNodesOnDrag">

+ 10053
- 0
examples/network/28_world_cup_network_performance.html
File diff suppressed because it is too large
View File


+ 1
- 0
examples/network/index.html View File

@ -39,6 +39,7 @@
<p><a href="25_physics_configuration.html">25_physics_configuration.html</a></p> <p><a href="25_physics_configuration.html">25_physics_configuration.html</a></p>
<p><a href="26_staticSmoothCurves.html">26_staticSmoothCurves.html</a></p> <p><a href="26_staticSmoothCurves.html">26_staticSmoothCurves.html</a></p>
<p><a href="27_world_cup_network.html">27_world_cup_network.html</a></p> <p><a href="27_world_cup_network.html">27_world_cup_network.html</a></p>
<p><a href="28_world_cup_network_performance.html">28_world_cup_network_performance.html</a></p>
<p><a href="graphviz/graphviz_gallery.html">graphviz_gallery.html</a></p> <p><a href="graphviz/graphviz_gallery.html">graphviz_gallery.html</a></p>
</div> </div>

+ 33
- 28
lib/network/Edge.js View File

@ -939,42 +939,22 @@ Edge.prototype._getDistanceToEdge = function (x1,y1, x2,y2, x3,y3) { // x3,y3 is
yVia = via.y; yVia = via.y;
} }
var minDistance = 1e9; var minDistance = 1e9;
var i,t,x,y,dx,dy;
var distance;
var i,t,x,y, lastX, lastY;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
t = 0.1*i; t = 0.1*i;
x = Math.pow(1-t,2)*x1 + (2*t*(1 - t))*xVia + Math.pow(t,2)*x2; x = Math.pow(1-t,2)*x1 + (2*t*(1 - t))*xVia + Math.pow(t,2)*x2;
y = Math.pow(1-t,2)*y1 + (2*t*(1 - t))*yVia + Math.pow(t,2)*y2; y = Math.pow(1-t,2)*y1 + (2*t*(1 - t))*yVia + Math.pow(t,2)*y2;
dx = Math.abs(x3-x);
dy = Math.abs(y3-y);
minDistance = Math.min(minDistance,Math.sqrt(dx*dx + dy*dy));
if (i > 0) {
distance = this._getDistanceToLine(lastX,lastY,x,y, x3,y3);
minDistance = distance < minDistance ? distance : minDistance;
}
lastX = x; lastY = y;
} }
return minDistance return minDistance
} }
else { else {
var px = x2-x1,
py = y2-y1,
something = px*px + py*py,
u = ((x3 - x1) * px + (y3 - y1) * py) / something;
if (u > 1) {
u = 1;
}
else if (u < 0) {
u = 0;
}
var x = x1 + u * px,
y = y1 + u * py,
dx = x - x3,
dy = y - y3;
//# Note: If the actual distance does not matter,
//# if you only want to compare what this function
//# returns to other results of this function, you
//# can just return the squared distance instead
//# (i.e. remove the sqrt) to gain a little performance
return Math.sqrt(dx*dx + dy*dy);
return this._getDistanceToLine(x1,y1,x2,y2,x3,y3);
} }
} }
else { else {
@ -998,7 +978,32 @@ Edge.prototype._getDistanceToEdge = function (x1,y1, x2,y2, x3,y3) { // x3,y3 is
} }
}; };
Edge.prototype._getDistanceToLine = function(x1,y1,x2,y2,x3,y3) {
var px = x2-x1,
py = y2-y1,
something = px*px + py*py,
u = ((x3 - x1) * px + (y3 - y1) * py) / something;
if (u > 1) {
u = 1;
}
else if (u < 0) {
u = 0;
}
var x = x1 + u * px,
y = y1 + u * py,
dx = x - x3,
dy = y - y3;
//# Note: If the actual distance does not matter,
//# if you only want to compare what this function
//# returns to other results of this function, you
//# can just return the squared distance instead
//# (i.e. remove the sqrt) to gain a little performance
return Math.sqrt(dx*dx + dy*dy);
}
/** /**
* This allows the zoom level of the network to influence the rendering * This allows the zoom level of the network to influence the rendering

+ 13
- 4
lib/network/Network.js View File

@ -107,7 +107,7 @@ function Network (container, data, options) {
gap: 5, gap: 5,
altLength: undefined altLength: undefined
}, },
inheritColor: false // to, from, false, true (== from)
inheritColor: "from" // to, from, false, true (== from)
}, },
configurePhysics:false, configurePhysics:false,
physics: { physics: {
@ -186,7 +186,7 @@ function Network (container, data, options) {
roundness: 0.5 roundness: 0.5
}, },
dynamicSmoothCurves: true, dynamicSmoothCurves: true,
maxVelocity: 10,
maxVelocity: 30,
minVelocity: 0.1, // px/s minVelocity: 0.1, // px/s
stabilizationIterations: 1000, // maximum number of iteration to stabilize stabilizationIterations: 1000, // maximum number of iteration to stabilize
labels:{ labels:{
@ -532,7 +532,6 @@ Network.prototype.setData = function(data, disableStart) {
} }
this._putDataInSector(); this._putDataInSector();
if (!disableStart) { if (!disableStart) {
// find a stable position or start animating to a stable position // find a stable position or start animating to a stable position
if (this.stabilize) { if (this.stabilize) {
@ -1779,7 +1778,7 @@ Network.prototype._redraw = function() {
this._doInAllSectors("_drawControlNodes",ctx); this._doInAllSectors("_drawControlNodes",ctx);
} }
// this._doInSupportSector("_drawNodes",ctx,true);
this._doInSupportSector("_drawNodes",ctx,true);
// this._drawTree(ctx,"#F00F0F"); // this._drawTree(ctx,"#F00F0F");
// restore original scaling and translation // restore original scaling and translation
@ -2229,6 +2228,14 @@ Network.prototype._configureSmoothCurves = function(disableStart) {
} }
if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) { if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) {
this._createBezierNodes(); this._createBezierNodes();
// cleanup unused support nodes
for (var nodeId in this.sectors['support']['nodes']) {
if (this.sectors['support']['nodes'].hasOwnProperty(nodeId)) {
if (this.edges[this.sectors['support']['nodes'][nodeId]] === undefined) {
delete this.sectors['support']['nodes'][nodeId];
}
}
}
} }
else { else {
// delete the support nodes // delete the support nodes
@ -2240,6 +2247,8 @@ Network.prototype._configureSmoothCurves = function(disableStart) {
} }
} }
} }
this._updateCalculationNodes(); this._updateCalculationNodes();
if (!disableStart) { if (!disableStart) {
this.moving = true; this.moving = true;

+ 1
- 1
lib/network/Node.js View File

@ -179,7 +179,7 @@ Node.prototype.setProperties = function(properties, constants) {
// individual shape properties // individual shape properties
if (properties.shape !== undefined) {this.shape = properties.shape;} if (properties.shape !== undefined) {this.shape = properties.shape;}
if (properties.image !== undefined) {this.image = properties.image;} if (properties.image !== undefined) {this.image = properties.image;}
if (properties.radius !== undefined) {this.radius = properties.radius;}
if (properties.radius !== undefined) {this.radius = properties.radius; this.baseRadiusValue = this.radius;}
if (properties.color !== undefined) {this.color = util.parseColor(properties.color);} if (properties.color !== undefined) {this.color = util.parseColor(properties.color);}
if (properties.fontColor !== undefined) {this.fontColor = properties.fontColor;} if (properties.fontColor !== undefined) {this.fontColor = properties.fontColor;}

+ 1
- 1
lib/network/mixins/physics/PhysicsMixin.js View File

@ -95,7 +95,7 @@ exports._calculateForces = function () {
this._calculateGravitationalForces(); this._calculateGravitationalForces();
this._calculateNodeForces(); this._calculateNodeForces();
if (this.constants.springConstant > 0) {
if (this.constants.physics.springConstant > 0) {
if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) { if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) {
this._calculateSpringForcesWithSupport(); this._calculateSpringForcesWithSupport();
} }

Loading…
Cancel
Save