Add options for hybrid

This commit is contained in:
Pitchaya Boonsarngsuk
2018-01-15 13:47:45 +00:00
parent c11c902e69
commit f67016c3f1
2 changed files with 50 additions and 17 deletions

View File

@@ -56,7 +56,10 @@ var MULTIPLIER = 50,
FULL_ITERATIONS = 20,
NODE_SIZE = 10,
COLOR_ATTRIBUTE = "",
SELECTED_DISTANCE = 10;
SELECTED_DISTANCE = 10,
FULL_NEIGHBOUR_SIZE = 6,
FULL_SAMPLE_SIZE = 3,
FULL_SELECTED_DISTANCE = 10;
// Create a color scheme for a range of numbers.
var color = d3.scaleOrdinal(d3.schemeCategory10);
@@ -105,6 +108,15 @@ function processData(data, error) {
props.forEach(function (d) {
opts.add(new Option(d, d, (d === COLOR_ATTRIBUTE) ? true : false));
});
opts.selectedIndex = props.length-1;
props.pop(); //Hide Iris index / last column from distance function
//Put the nodes in random starting positions
nodes.forEach(function (d) {
d.x = (Math.random()-0.5) * 100000;
d.y = (Math.random()-0.5) * 100000;
});
// Add the nodes to DOM.
node = svg.append("g")
@@ -264,7 +276,7 @@ function startNeighbourSamplingSimulation() {
.neighbourSize(NEIGHBOUR_SIZE)
.sampleSize(SAMPLE_SIZE)
// .freeness(0.5)
.distanceRange(SELECTED_DISTANCE)
.distanceRange(SELECTED_DISTANCE * MULTIPLIER)
// The distance function that will be used to calculate distances
// between nodes.
.distance(function (s, t) {
@@ -296,8 +308,8 @@ function startHybridSimulation() {
.neighbourSize(NEIGHBOUR_SIZE)
.sampleSize(SAMPLE_SIZE);
var sample = hybridSimulation.sample();
var remainder = hybridSimulation.remainder();
let sample = hybridSimulation.sample();
let remainder = hybridSimulation.remainder();
// Add the nodes to DOM.
node = svg.append("g")
@@ -334,16 +346,13 @@ function startHybridSimulation() {
unSelectNodes(selectedData);
}
hybridSimulation
.distance(distanceFunction);
hybridSimulation
.on("sampleTick", tickedHybrid)
.on("fullTick", tickedHybrid)
.on("startFull", started)
.on("startFull", startedFull)
.on("end", endedHybrid);
function tickedHybrid() {
if (rendering === true) {
node
@@ -356,7 +365,7 @@ function startHybridSimulation() {
}
}
function started() {
function startedFull() {
d3.selectAll(".nodes").remove();
// Add the nodes to DOM.
node = svg.append("g")