Add options for hybrid
This commit is contained in:
@@ -145,23 +145,47 @@
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<label title="Number of iterations done at the end">
|
||||
Full iterations
|
||||
<output id="fullIterationsSliderOutput">20</output><br/>
|
||||
<input type="range" min="1" max="100" value="20" step="1" oninput="d3.select('#fullIterationsSliderOutput').text(value); FULL_ITERATIONS=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="NeighbourSize">
|
||||
Neighbour Set
|
||||
Subset: Neighbour Set
|
||||
<output id="hlneighbourSizeSliderOutput">6</output><br/>
|
||||
<input type="range" min="1" max="100" value="6" step="1" oninput="d3.select('#hlneighbourSizeSliderOutput').text(value); NEIGHBOUR_SIZE=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="SampleSize">
|
||||
Sample Set
|
||||
Subset: Sample Set
|
||||
<output id="hlsampleSizeSliderOutput">3</output><br/>
|
||||
<input type="range" min="1" max="100" value="3" step="1" oninput="d3.select('#hlsampleSizeSliderOutput').text(value); SAMPLE_SIZE=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="DistanceRange">
|
||||
Subset: Distance Range
|
||||
<output id="hldistanceRangeSliderOutput">10</output><br/>
|
||||
<input type="range" min="1" max="100" value="10" step="1" oninput="d3.select('#hldistanceRangeSliderOutput').text(value); SELECTED_DISTANCE=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="Number of iterations done at the end">
|
||||
Full: Iterations
|
||||
<output id="fullIterationsSliderOutput">20</output><br/>
|
||||
<input type="range" min="1" max="100" value="20" step="1" oninput="d3.select('#fullIterationsSliderOutput').text(value); FULL_ITERATIONS=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="Full NeighbourSize">
|
||||
Full: Neighbour Set
|
||||
<output id="hlFullneighbourSizeSliderOutput">6</output><br/>
|
||||
<input type="range" min="1" max="100" value="6" step="1" oninput="d3.select('#hlFullneighbourSizeSliderOutput').text(value); FULL_NEIGHBOUR_SIZE=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="Full SampleSize">
|
||||
Full: Sample Set
|
||||
<output id="hlFullsampleSizeSliderOutput">3</output><br/>
|
||||
<input type="range" min="1" max="100" value="3" step="1" oninput="d3.select('#hlFullsampleSizeSliderOutput').text(value); FULL_SAMPLE_SIZE=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="DistanceRange">
|
||||
Full: Distance Range
|
||||
<output id="hlFulldistanceRangeSliderOutput">10</output><br/>
|
||||
<input type="range" min="1" max="100" value="10" step="1" oninput="d3.select('#hlFulldistanceRangeSliderOutput').text(value); FULL_SELECTED_DISTANCE=value;">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<input id="NSButton" type="radio" name="algorithm" onclick="d3.select('#startSimulation').on('click', startNeighbourSamplingSimulation)">Neighbour
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user