Modify stop condition in the example

This commit is contained in:
Pitchaya Boonsarngsuk
2018-01-26 17:29:33 +00:00
parent 97d8b71963
commit 9d6b3e066b
5 changed files with 27 additions and 12 deletions

View File

@@ -157,6 +157,12 @@
<input type="range" min="1" max="100" value="3" step="1" oninput="d3.select('#hlsampleSizeSliderOutput').text(value); SAMPLE_SIZE=value;">
</label>
<br/>
<label title="InterpEndingIts">
Interpolation: Micro-adjustment Its
<output id="hlInterpEdningSliderOutput">20</output><br/>
<input type="range" min="1" max="50" value="20" step="1" oninput="d3.select('#hlInterpEdningSliderOutput').text(value); INTERP_ENDING_ITS=value;">
</label>
<br/>
<label title="Number of iterations done at the end">
Full: Iterations
<output id="fullIterationsSliderOutput">20</output><br/>

View File

@@ -43,7 +43,8 @@ var nodes, // as in Data points
clickedIndex = -1,
paused = false,
alreadyRanIterations,
tweakedVerOfLink;
tweakedVerOfLink,
manualStop = false;
// Default parameters
var MULTIPLIER = 50,
@@ -58,7 +59,8 @@ var MULTIPLIER = 50,
NODE_SIZE = 10,
COLOR_ATTRIBUTE = "",
FULL_NEIGHBOUR_SIZE = 6,
FULL_SAMPLE_SIZE = 3;
FULL_SAMPLE_SIZE = 3,
INTERP_ENDING_ITS = 20;
// Create a color scheme for a range of numbers.
var color = d3.scaleOrdinal(d3.schemeCategory10);
@@ -135,8 +137,6 @@ function processData(data, error) {
// Pass the nodes to the D3 force simulation.
simulation
.nodes(nodes)
.on("tick", ticked)
.on("end", ended)
.stop();
};
@@ -202,13 +202,14 @@ function ticked() {
if (springForce) {
intercom.emit("passedData", simulation.force(forceName).distributionData());
}
if(alreadyRanIterations == ITERATIONS) {
if(manualStop && alreadyRanIterations == ITERATIONS) {
ended();
}
}
function ended() {
simulation.stop();
simulation.force(forceName, null);
console.log("ended");
if (rendering !== true) { // Never drawn anything before? Now it's time.
node
@@ -382,7 +383,7 @@ function updateDistanceRange() {
function pauseUnPause() {
if (simulation) {
if (paused) {
simulation.force(forceName).distanceRange(SELECTED_DISTANCE);
simulation.force(forceName);
simulation.restart();
d3.select("#pauseButton").text("Pause");
paused = false;

View File

@@ -5,6 +5,7 @@ function startHybridSimulation() {
console.log("startHybridSimulation");
springForce = false;
d3.selectAll(".nodes").remove();
manualStop = false;
simulation.stop();
p1 = performance.now();

View File

@@ -5,6 +5,7 @@ function startLinkSimulation() {
console.log("startLinkSimulation")
springForce = false;
alreadyRanIterations = 0;
manualStop = true;
simulation.stop();
p1 = performance.now();
let links = [];
@@ -37,10 +38,13 @@ function startLinkSimulation() {
return distanceFunction(n.source, n.target, props, norm);
})
.links(links);
simulation.force(forceName,force)
.alphaDecay(0)
//.velocityDecay(0.8)
.alpha(1)
.restart();
simulation
.alphaDecay(0)
.alpha(1)
.on("tick", ticked)
.on("end", ended)
//.velocityDecay(0.8)
.force(forceName,force)
.restart();
}

View File

@@ -5,6 +5,7 @@ function startNeighbourSamplingSimulation() {
console.log("startNeighbourSamplingSimulation");
//springForce = true;
alreadyRanIterations = 0;
manualStop = true;
simulation.stop();
p1 = performance.now();
@@ -20,6 +21,8 @@ function startNeighbourSamplingSimulation() {
simulation
.alphaDecay(0)
.alpha(1)
.on("tick", ticked)
.on("end", ended)
.force(forceName, force);
// Restart the simulation.
console.log(simulation.force(forceName).neighbourSize(), simulation.force(forceName).sampleSize());