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

@@ -145,23 +145,47 @@
</div> </div>
</div> </div>
<br/> <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"> <label title="NeighbourSize">
Neighbour Set Subset: Neighbour Set
<output id="hlneighbourSizeSliderOutput">6</output><br/> <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;"> <input type="range" min="1" max="100" value="6" step="1" oninput="d3.select('#hlneighbourSizeSliderOutput').text(value); NEIGHBOUR_SIZE=value;">
</label> </label>
<br/> <br/>
<label title="SampleSize"> <label title="SampleSize">
Sample Set Subset: Sample Set
<output id="hlsampleSizeSliderOutput">3</output><br/> <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;"> <input type="range" min="1" max="100" value="3" step="1" oninput="d3.select('#hlsampleSizeSliderOutput').text(value); SAMPLE_SIZE=value;">
</label> </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> </div>
<input id="NSButton" type="radio" name="algorithm" onclick="d3.select('#startSimulation').on('click', startNeighbourSamplingSimulation)">Neighbour <input id="NSButton" type="radio" name="algorithm" onclick="d3.select('#startSimulation').on('click', startNeighbourSamplingSimulation)">Neighbour

View File

@@ -56,7 +56,10 @@ var MULTIPLIER = 50,
FULL_ITERATIONS = 20, FULL_ITERATIONS = 20,
NODE_SIZE = 10, NODE_SIZE = 10,
COLOR_ATTRIBUTE = "", 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. // Create a color scheme for a range of numbers.
var color = d3.scaleOrdinal(d3.schemeCategory10); var color = d3.scaleOrdinal(d3.schemeCategory10);
@@ -105,6 +108,15 @@ function processData(data, error) {
props.forEach(function (d) { props.forEach(function (d) {
opts.add(new Option(d, d, (d === COLOR_ATTRIBUTE) ? true : false)); 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. // Add the nodes to DOM.
node = svg.append("g") node = svg.append("g")
@@ -264,7 +276,7 @@ function startNeighbourSamplingSimulation() {
.neighbourSize(NEIGHBOUR_SIZE) .neighbourSize(NEIGHBOUR_SIZE)
.sampleSize(SAMPLE_SIZE) .sampleSize(SAMPLE_SIZE)
// .freeness(0.5) // .freeness(0.5)
.distanceRange(SELECTED_DISTANCE) .distanceRange(SELECTED_DISTANCE * MULTIPLIER)
// The distance function that will be used to calculate distances // The distance function that will be used to calculate distances
// between nodes. // between nodes.
.distance(function (s, t) { .distance(function (s, t) {
@@ -296,8 +308,8 @@ function startHybridSimulation() {
.neighbourSize(NEIGHBOUR_SIZE) .neighbourSize(NEIGHBOUR_SIZE)
.sampleSize(SAMPLE_SIZE); .sampleSize(SAMPLE_SIZE);
var sample = hybridSimulation.sample(); let sample = hybridSimulation.sample();
var remainder = hybridSimulation.remainder(); let remainder = hybridSimulation.remainder();
// Add the nodes to DOM. // Add the nodes to DOM.
node = svg.append("g") node = svg.append("g")
@@ -334,16 +346,13 @@ function startHybridSimulation() {
unSelectNodes(selectedData); unSelectNodes(selectedData);
} }
hybridSimulation
.distance(distanceFunction);
hybridSimulation hybridSimulation
.on("sampleTick", tickedHybrid) .on("sampleTick", tickedHybrid)
.on("fullTick", tickedHybrid) .on("fullTick", tickedHybrid)
.on("startFull", started) .on("startFull", startedFull)
.on("end", endedHybrid); .on("end", endedHybrid);
function tickedHybrid() { function tickedHybrid() {
if (rendering === true) { if (rendering === true) {
node node
@@ -356,7 +365,7 @@ function startHybridSimulation() {
} }
} }
function started() { function startedFull() {
d3.selectAll(".nodes").remove(); d3.selectAll(".nodes").remove();
// Add the nodes to DOM. // Add the nodes to DOM.
node = svg.append("g") node = svg.append("g")