diff --git a/README.md b/README.md index 47572dd..8f40404 100644 --- a/README.md +++ b/README.md @@ -151,9 +151,9 @@ The hybrid layout algorithm reduces the computation power usage even further by Creates a new hybrid layout simulation default parameters. The simulation will takeover control of [d3.forceSimulation](https://github.com/d3/d3-force#forceSimulation) provided (*simulation* parameter). *forceSample* and *forceFull* are pre-configured [d3.forceNeighbourSampling](#forceNeighbourSampling) forces to be run over the $\sqrt{n}$ samples and full dataset respectively. While unsupported, other D3 forces such as [d3.forceLinkFullyConnected](forceLinkFullyConnected) may also work. -*forceSample* may have [stableVelocity](neighbourSampling_stableVelocity) configured to end the simulation and begin the interpolation phase early, but any [handler](neighbourSampling_onStableVelo) functions will be replaced be hybridSimulation's own internal function. +*forceSample* and *forceFull* may have [stableVelocity](neighbourSampling_stableVelocity) configured to end the simulation and begin the interpolation phase early, but any [handler](neighbourSampling_onStableVelo) functions will be replaced be hybridSimulation's own internal function. -*forceSample* may be absent, null, or undefined to skip the final refinement. +*forceFull* may also be absent, null, or undefined to skip the final refinement. *simulation* should have already been loaded with nodes. If there are any changes in the list of nodes, the simulation have to be re-set using the [.simulation](#hybrid_simulation) method. @@ -175,7 +175,7 @@ If *force* is specified, sets the neighbour and sampling force to run on the $\s # *hybrid*.**forceFull**([*force*]) -If *force* is specified, sets the neighbour and sampling force to run on the whole dataset after interpolation and returns this layout simulation. If set to null, the process will be skipped. If *force* is not specified, returns the current force object. +If *force* is specified, sets the neighbour and sampling force to run on the whole dataset after interpolation and returns this layout simulation. The same limitation applies: [stableVelocity](neighbourSampling_stableVelocity) may be configured to end the simulation and begin the interpolation phase early, but any [handler](neighbourSampling_onStableVelo) functions will be replaced be hybridSimulation's own internal function. If set to null, the process will be skipped. If *force* is not specified, returns the current force object. # *hybrid*.**sampleIterations**([*iterations*]) diff --git a/src/hybridSimulation.js b/src/hybridSimulation.js index 6131b8d..8e983ea 100644 --- a/src/hybridSimulation.js +++ b/src/hybridSimulation.js @@ -63,6 +63,10 @@ export default function (sim, forceS, forceF) { forceSample.onStableVelo(sampleEnded); } + if (forceFull.onStableVelo) { + forceFull.onStableVelo(fullEnded); + } + // Set default value for interpDistanceFn if not been specified yet if(interpDistanceFn === undefined) { if(forceFull.distance == 'function') @@ -96,6 +100,11 @@ export default function (sim, forceS, forceF) { function fullTick() { event.call("fullTick"); if(++alreadyRanIterations >= FULL_ITERATIONS){ + fullEnded(); + } + } + + function fullEnded() { simulation.stop(); initAlready = false; simulation.force("Full force", null);