Browse Source

finalized docs and zoom

css_transitions
Alex de Mulder 11 years ago
parent
commit
9d225542b9
3 changed files with 24 additions and 19 deletions
  1. +2
    -1
      docs/graph.html
  2. +21
    -17
      src/graph/Graph.js
  3. +1
    -1
      src/graph/graphMixins/ClusterMixin.js

+ 2
- 1
docs/graph.html View File

@ -1305,7 +1305,8 @@ var options: {
for the add and edit functions. The data the user is supplied with in these functions has been described in the code below.
For the add data, you can add any and all options that are accepted for node creation as described above. The same goes for edit, however only the fields described
in the code below contain information on the selected node. The callback for connect accepts any options that are used for edge creation. Only the callback for delete selected
requires the same data structure that is supplied to the user.
requires the same data structure that is supplied to the user. <br /><br />
<b>If there is no injected function supplied for the edit operation, the button will not be shown in the toolbar.</b>
</p>
<pre class="prettyprint">
// If a variable is not supplied, the default value is used.

+ 21
- 17
src/graph/Graph.js View File

@ -216,7 +216,7 @@ function Graph (container, data, options) {
};
// properties for the animation
this.moving = false; // True if any of the nodes have an undefined position
this.moving = true;
this.timer = undefined; // Scheduling function. Is definded in this.start();
// load data (the disable start variable will be the same as the enabled clustering)
@ -305,7 +305,7 @@ Graph.prototype._centerGraph = function(range) {
*
* @param {Boolean} [initialZoom] | zoom based on fitted formula or range, true = fitted, default = false;
*/
Graph.prototype.zoomToFit = function(initialZoom, doNotStart) {
Graph.prototype.zoomToFit = function(initialZoom, disableStart) {
if (initialZoom === undefined) {
initialZoom = false;
}
@ -315,12 +315,23 @@ Graph.prototype.zoomToFit = function(initialZoom, doNotStart) {
var zoomLevel;
if (initialZoom == true) {
if (this.constants.clustering.enabled == true &&
if (this.constants.smoothCurves == true) {
if (this.constants.clustering.enabled == true &&
numberOfNodes >= this.constants.clustering.initialMaxNodes) {
zoomLevel = 77.5271985 / (numberOfNodes + 187.266146) + 4.76710517e-05; // this is obtained from fitting a dataset from 5 points with scale levels that looked good.
zoomLevel = 49.07548 / (numberOfNodes + 142.05338) + 9.1444e-04; // this is obtained from fitting a dataset from 5 points with scale levels that looked good.
}
else {
zoomLevel = 12.662 / (numberOfNodes + 7.4147) + 0.0964822; // this is obtained from fitting a dataset from 5 points with scale levels that looked good.
}
}
else {
zoomLevel = 30.5062972 / (numberOfNodes + 19.93597763) + 0.08413486; // this is obtained from fitting a dataset from 5 points with scale levels that looked good.
if (this.constants.clustering.enabled == true &&
numberOfNodes >= this.constants.clustering.initialMaxNodes) {
zoomLevel = 77.5271985 / (numberOfNodes + 187.266146) + 4.76710517e-05; // this is obtained from fitting a dataset from 5 points with scale levels that looked good.
}
else {
zoomLevel = 30.5062972 / (numberOfNodes + 19.93597763) + 0.08413486; // this is obtained from fitting a dataset from 5 points with scale levels that looked good.
}
}
}
else {
@ -340,7 +351,7 @@ Graph.prototype.zoomToFit = function(initialZoom, doNotStart) {
this.pinch.mousewheelScale = zoomLevel;
this._setScale(zoomLevel);
this._centerGraph(range);
if (doNotStart == false || doNotStart === undefined) {
if (disableStart == false || disableStart === undefined) {
this.start();
}
};
@ -404,7 +415,6 @@ Graph.prototype.setData = function(data, disableStart) {
if (this.stabilize) {
this._doStabilize();
}
this.moving = true;
this.start();
}
};
@ -579,7 +589,6 @@ Graph.prototype.setOptions = function (options) {
this.setSize(this.width, this.height);
this._setTranslation(this.frame.clientWidth / 2, this.frame.clientHeight / 2);
this._setScale(1);
this.zoomToFit();
this._redraw();
};
@ -1679,19 +1688,14 @@ Graph.prototype._drawEdges = function(ctx) {
* @private
*/
Graph.prototype._doStabilize = function() {
//var start = new Date();
// find stable position
var count = 0;
var vmin = this.constants.minVelocity;
var stable = false;
while (!stable && count < this.constants.maxIterations) {
this._initializeForceCalculation();
this._discreteStepNodes();
stable = !this._isMoving(vmin);
while (this.moving && count < this.constants.maxIterations) {
this._physicsTick();
count++;
}
this.zoomToFit();
this.zoomToFit(false,true);
};

+ 1
- 1
src/graph/graphMixins/ClusterMixin.js View File

@ -1045,7 +1045,7 @@ var ClusterMixin = {
for (var i = 0; i < this.nodeIndices.length; i++) {
var node = this.nodes[this.nodeIndices[i]];
if ((node.xFixed == false || node.yFixed == false) && this.createNodeOnClick != true) {
var radius = this.constants.physics.springLength * node.mass;
var radius = this.constants.physics.springLength * Math.min(100,node.mass);
var angle = 2 * Math.PI * Math.random();
if (node.xFixed == false) {node.x = radius * Math.cos(angle);}
if (node.yFixed == false) {node.y = radius * Math.sin(angle);}

Loading…
Cancel
Save