Init from given files
This commit is contained in:
291
examples/d3-force-neighbourSampling-papaparsing.html
Normal file
291
examples/d3-force-neighbourSampling-papaparsing.html
Normal file
@@ -0,0 +1,291 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
h1 {
|
||||
text-align: center;
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
.links line {
|
||||
stroke: #999;
|
||||
stroke-opacity: 0.6;
|
||||
}
|
||||
/*.nodes circle {
|
||||
stroke: #fff;
|
||||
stroke-width: 1.5px;
|
||||
}*/
|
||||
|
||||
circle:hover {
|
||||
fill: #8B0000;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.notSelected {
|
||||
fill: #999;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.highlighted {
|
||||
fill: black;
|
||||
}
|
||||
|
||||
#svg {
|
||||
border-style: solid;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.left {
|
||||
float: left;
|
||||
width: 32%;
|
||||
}
|
||||
|
||||
.controls {
|
||||
flex-basis: 200px;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
.controls input[type="range"] {
|
||||
margin: 0 5% 0.5em 5%;
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
.multiplier {
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
.parameters {
|
||||
margin: 10px 0 10px 30px;
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
.start {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.tooltip {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
padding: 5px;
|
||||
font: 12px sans-serif;
|
||||
background: lightsteelblue;
|
||||
border: 0px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
<h1>Evaluation</h1>
|
||||
<svg id="svg" width="100%" height="600">
|
||||
<div class="left controls">
|
||||
|
||||
<div class="input">
|
||||
<input type="file" id="csv-file" name="files">
|
||||
</div>
|
||||
|
||||
<div class="multiplier">
|
||||
<label title="The size of the nodes">
|
||||
Node size
|
||||
<output id="nodeSizeSliderOutput">10</output>
|
||||
<input type="range" min="5" max="200" value="10" step="5" oninput="d3.select('#nodeSizeSliderOutput').text(value); NODE_SIZE=value; d3.selectAll('circle').attr('r', value)">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="The number that distance is multiplied by in order to improve the visibility of the graph">
|
||||
distanceMultiplier
|
||||
<output id="distanceMultiplierSliderOutput">50</output>
|
||||
<input type="range" min="5" max="1000" value="50" step="5" oninput="d3.select('#distanceMultiplierSliderOutput').text(value); MULTIPLIER=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="Number of iterations before the simulation is stopped">
|
||||
Iterations
|
||||
<output id="iterationsSliderOutput">300</output>
|
||||
<input type="range" min="5" max="5000" value="300" step="5" oninput="d3.select('#iterationsSliderOutput').text(value); ITERATIONS=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="Attribute used for coloring nodes">
|
||||
Color attribute
|
||||
<select id="color_attr" onchange="COLOR_ATTRIBUTE=value; colorToAttribute();">
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label title="js/">
|
||||
Rendering
|
||||
<input type="checkbox" checked onclick="rendering=!rendering;">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="start">
|
||||
<button id="startSimulation" form="algorithmForm">Start</button>
|
||||
<button id="pauseButton" onclick="pauseUnPause()">Pause</button>
|
||||
<button onclick="stopSimulation()">Stop</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="left">
|
||||
<p>Select algorithm:</p>
|
||||
<div id="algorithms">
|
||||
<input id="HLButton" type="radio" name="algorithm" onclick="d3.select('#startSimulation').on('click', startHybridSimulation)">Hybrid
|
||||
layout
|
||||
<br>
|
||||
<div id="HLParameters" class="parameters" style="display:none">
|
||||
<div id="pivots">
|
||||
<input id="BFButton" type="radio" name="pivots" checked="checked" onclick="PIVOTS=false;">Brute-force<br>
|
||||
<input id="PButton" type="radio" name="pivots" onclick="PIVOTS=true;">Pivots<br>
|
||||
<div id="numPivots" class="parameters" style="display:none">
|
||||
<label title="The number of pivots">
|
||||
Number of Pivots
|
||||
<output id="numPivotsSliderOutput">3</output><br/>
|
||||
<input type="range" min="1" max="50" value="3" step="1" oninput="d3.select('#numPivotsSliderOutput').text(value); NUM_PIVOTS=value;">
|
||||
</label>
|
||||
</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
|
||||
<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
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<input id="NSButton" type="radio" name="algorithm" onclick="d3.select('#startSimulation').on('click', startNeighbourSamplingSimulation)">Neighbour
|
||||
and Sampling<br>
|
||||
<div id="NSParameters" class="parameters" style="display:none">
|
||||
<label title="NeighbourSize">
|
||||
Neighbour Set
|
||||
<output id="neighbourSizeSliderOutput">6</output><br/>
|
||||
<input type="range" min="1" max="100" value="6" step="1" oninput="d3.select('#neighbourSizeSliderOutput').text(value); NEIGHBOUR_SIZE=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="SampleSize">
|
||||
Sample Set
|
||||
<output id="sampleSizeSliderOutput">3</output><br/>
|
||||
<input type="range" min="1" max="100" value="3" step="1" oninput="d3.select('#sampleSizeSliderOutput').text(value); SAMPLE_SIZE=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="DistanceRange">
|
||||
Distance Range
|
||||
<output id="distanceRangeSliderOutput">10</output><br/>
|
||||
<input type="range" min="1" max="100" value="10" step="1" oninput="d3.select('#distanceRangeSliderOutput').text(value); SELECTED_DISTANCE=value;">
|
||||
</label>
|
||||
</div>
|
||||
<input class="noParameters" type="radio" name="algorithm" onclick="d3.select('#startSimulation').on('click', startLinkSimulation)">Link
|
||||
force in D3<br>
|
||||
<input class="noParameters" type="radio" name="algorithm" onclick="d3.select('#startSimulation').on('click', startBarnesHutSimulation)">Barnes-Hut<br>
|
||||
<input id="tSNEButton" type="radio" name="algorithm" onclick="d3.select('#startSimulation').on('click', starttSNE)">t-SNE<br>
|
||||
<div id="tSNEParameters" class="parameters" style="display:none">
|
||||
<label title="Perplexity">
|
||||
Perplexity
|
||||
<output id="perplexitySliderOutput">30</output><br/>
|
||||
<input type="range" min="1" max="500" value="30" step="1" oninput="d3.select('#perplexitySliderOutput').text(value); PERPLEXITY=value;">
|
||||
</label>
|
||||
<br/>
|
||||
<label title="LearningRate">
|
||||
Learning Rate
|
||||
<output id="learningRateSliderOutput">10</output><br/>
|
||||
<input type="range" min="1" max="500" value="10" step="1" oninput="d3.select('#learningRateSliderOutput').text(value); LEARNING_RATE=value;">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="left">
|
||||
<p>Select distance function:</p>
|
||||
<div id="distance">
|
||||
<input type="radio" name="distance" onclick="distanceFunction=calculateDistance"> General<br>
|
||||
<input type="radio" name="distance" onclick="distanceFunction=calculateEuclideanDistance"> Euclidean<br>
|
||||
<input type="radio" name="distance" onclick="distanceFunction=calculateManhattanDistance"> Manhattan<br>
|
||||
<input type="radio" name="distance" onclick="distanceFunction=calculateJaccardDissimilarity"> Jaccard<br>
|
||||
<input type="radio" name="distance" onclick="distanceFunction=calculateDiceDissimilarity"> Dice<br>
|
||||
<input type="radio" name="distance" onclick="distanceFunction=calculateCosineSimilarity"> Cosine<br>
|
||||
<input type="radio" name="distance" onclick="distanceFunction=calculateDistancePoker"> Poker Hands<br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</svg>
|
||||
</body>
|
||||
|
||||
<!-- Load the files and libraries used. -->
|
||||
<script src="js/lib/d3.v4.min.js"></script>
|
||||
<script src="js/lib/papaparse.js"></script>
|
||||
<script src="js/lib/jquery-3.1.1.js"></script>
|
||||
<script src="js/lib/intercom.js"></script>
|
||||
<script src="../build/d3-neighbour-sampling.js"></script>
|
||||
<script src="js/src/neighbourSampling-papaparsing.js"></script>
|
||||
<script src="js/distances/distancePokerHands.js"></script>
|
||||
<script src="js/distances/distance.js"></script>
|
||||
<script src="js/distances/euclideanDistance.js"></script>
|
||||
<script src="js/distances/euclideanDistanceInTSNE.js"></script>
|
||||
<script src="js/distances/manhattanDistance.js"></script>
|
||||
<script src="js/distances/jaccardDissimilarity.js"></script>
|
||||
<script src="js/distances/diceDissimilarity.js"></script>
|
||||
<script src="js/distances/cosineSimilarity.js"></script>
|
||||
<script src="js/distances/normalization.js"></script>
|
||||
<script src="js/distances/numeric.js"></script>
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("#csv-file").change(function (d) {
|
||||
parseFile(d);
|
||||
$("#color_attr option").remove();
|
||||
$("#pauseButton").text("Pause");
|
||||
paused = false;
|
||||
});
|
||||
|
||||
$("#startSimulation").click(function () {
|
||||
$("#pauseButton").text("Pause");
|
||||
paused = false;
|
||||
});
|
||||
|
||||
$("#tSNEButton").click(function () {
|
||||
$(".parameters").hide();
|
||||
$("#tSNEParameters").show();
|
||||
});
|
||||
|
||||
$("#NSButton").click(function () {
|
||||
$(".parameters").hide();
|
||||
$("#NSParameters").show();
|
||||
});
|
||||
|
||||
$("#HLButton").click(function () {
|
||||
$(".parameters").hide();
|
||||
$("#HLParameters").show();
|
||||
if ($("#PButton").is(":checked")) {
|
||||
$("#numPivots").show();
|
||||
}
|
||||
});
|
||||
|
||||
$("#BFButton").click(function () {
|
||||
$("#numPivots").hide();
|
||||
});
|
||||
|
||||
$("#PButton").click(function () {
|
||||
$("#numPivots").show();
|
||||
});
|
||||
|
||||
$(".noParameters").click(function () {
|
||||
$(".parameters").hide();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user