Added comment, clean up stub API
This commit is contained in:
10
src/link.js
10
src/link.js
@@ -4,6 +4,7 @@ import jiggle from "./jiggle";
|
|||||||
/**
|
/**
|
||||||
* Modified link force algorithm
|
* Modified link force algorithm
|
||||||
* - simplify calculations for parameters locked for spring model
|
* - simplify calculations for parameters locked for spring model
|
||||||
|
* - replace the use of links {} with loop. greatly reduce memory usage
|
||||||
* - removed other unused functions
|
* - removed other unused functions
|
||||||
* Alpha should be constant 1 for accurate simulation
|
* Alpha should be constant 1 for accurate simulation
|
||||||
*/
|
*/
|
||||||
@@ -39,6 +40,7 @@ export default function(links) {
|
|||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
if (!nodes) return;
|
if (!nodes) return;
|
||||||
|
// 0.5 to divide the force to two part for source and target node
|
||||||
dataSizeFactor = 0.5/(nodes.length-1);
|
dataSizeFactor = 0.5/(nodes.length-1);
|
||||||
initializeDistance();
|
initializeDistance();
|
||||||
}
|
}
|
||||||
@@ -57,14 +59,6 @@ export default function(links) {
|
|||||||
initialize();
|
initialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
force.links = function(_) {
|
|
||||||
return arguments.length ? (links = _, initialize(), force) : links;
|
|
||||||
};
|
|
||||||
|
|
||||||
force.id = function(_) {
|
|
||||||
return arguments.length ? (id = _, force) : id;
|
|
||||||
};
|
|
||||||
|
|
||||||
force.iterations = function(_) {
|
force.iterations = function(_) {
|
||||||
return arguments.length ? (iterations = +_, force) : iterations;
|
return arguments.length ? (iterations = +_, force) : iterations;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user