Clean up old codes

This commit is contained in:
Pitchaya Boonsarngsuk
2018-01-03 10:32:40 +07:00
parent 1f53efb988
commit 0101245e9e
5 changed files with 27 additions and 22 deletions

View File

@@ -65,6 +65,6 @@ function calculateDistance(source, target, properties, normArgs) {
sumDiff *= properties.length/cols; sumDiff *= properties.length/cols;
} }
console.log(sumDiff); //console.log(sumDiff);
return sumDiff; return sumDiff;
} }

View File

@@ -25,9 +25,8 @@ var intercom = Intercom.getInstance();
intercom.on("select", unSelectNodes); intercom.on("select", unSelectNodes);
var links = [], var nodes, // as in Data points
nodes, node, // as in SVG object that have all small circles on screen
node,
props, props,
norm, norm,
p1 = 0, p1 = 0,

View File

@@ -1,11 +1,11 @@
export { /*export {
default as forceNeighbourSampling default as forceNeighbourSampling
} }
from "./src/neighbourSampling"; from "./src/neighbourSampling";
export { export {
default as forceNeighbourSamplingPre default as forceNeighbourSamplingPre
} }
from "./src/neighbourSamplingPre"; from "./src/neighbourSamplingPre";*/
export { export {
default as forceNeighbourSamplingDistance default as forceNeighbourSamplingDistance
} }

View File

@@ -36,9 +36,11 @@ export default function(links) {
} }
function force(alpha) { function force(alpha) {
for (var k = 0, n = links.length; k < iterations; ++k) { for (var k = 0, n = links.length; k < iterations; ++k) { // Each iteration in a tick
for (var i = 0, link, source, target, x, y, l, b; i < n; ++i) { for (var i = 0, link, source, target, x, y, l, b; i < n; ++i) { //For each link
link = links[i], source = link.source, target = link.target; link = links[i];
source = link.source;
target = link.target;
x = target.x + target.vx - source.x - source.vx || jiggle(); x = target.x + target.vx - source.x - source.vx || jiggle();
y = target.y + target.vy - source.y - source.vy || jiggle(); y = target.y + target.vy - source.y - source.vy || jiggle();
l = Math.sqrt(x * x + y * y); l = Math.sqrt(x * x + y * y);
@@ -66,14 +68,17 @@ export default function(links) {
} }
for (i = 0; i < m; ++i) { for (i = 0; i < m; ++i) {
link = links[i], link.index = i; link = links[i];
if (typeof link.source !== "object") link.source = find(nodeById, link.source); link.index = i;
if (typeof link.target !== "object") link.target = find(nodeById, link.target); //if (typeof link.source !== "object") link.source = find(nodeById, link.source);
++count[link.source.index], ++count[link.target.index]; //if (typeof link.target !== "object") link.target = find(nodeById, link.target);
++count[link.source.index];
++count[link.target.index];
} }
for (i = 0, bias = new Array(m); i < m; ++i) { for (i = 0, bias = new Array(m); i < m; ++i) {
link = links[i], bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]); link = links[i];
bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]);
} }
strengths = new Array(m), initializeStrength(); strengths = new Array(m), initializeStrength();

View File

@@ -26,9 +26,9 @@ export default function () {
nodes, nodes,
neighbourSize = 6, neighbourSize = 6,
sampleSize = 3, sampleSize = 3,
freeness = 0.85, //freeness = 0.85,
springForce = 0.7, //springForce = 0.7,
dampingFactor = 0.3, //dampingFactor = 0.3,
velocity, velocity,
multiplier = 50; multiplier = 50;
@@ -99,8 +99,9 @@ export default function () {
neighbs = new Map([...neighbs.entries()].sort(sortDistances)); neighbs = new Map([...neighbs.entries()].sort(sortDistances));
neighbours[i] = neighbs; neighbours[i] = neighbs;
exclude.concat(neighbs); //exclude.concat(neighbs);
samples[i] = createRandomSample(i, exclude, n, sampleSize); //samples[i] = createRandomSample(i, exclude, n, sampleSize);
//Samples will be created at the start of each it anyway.
} }
} }
@@ -276,9 +277,9 @@ export default function () {
return getAvgVelocity(); return getAvgVelocity();
}; };
force.freeness = function (_) { /*force.freeness = function (_) {
return arguments.length ? (freeness = +_, force) : freeness; return arguments.length ? (freeness = +_, force) : freeness;
}; };*/
force.distanceRange = function (_) { force.distanceRange = function (_) {
return arguments.length ? (distanceRange = +_, force) : distanceRange; return arguments.length ? (distanceRange = +_, force) : distanceRange;