Edit comments
This commit is contained in:
@@ -65,7 +65,6 @@ var MULTIPLIER = 50,
|
|||||||
// 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);
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
distanceFunction = calculateDistance;
|
distanceFunction = calculateDistance;
|
||||||
d3.select('#startSimulation').on('click', startHybridSimulation);
|
d3.select('#startSimulation').on('click', startHybridSimulation);
|
||||||
@@ -82,7 +81,6 @@ function parseFile(evt) {
|
|||||||
springForce = false;
|
springForce = false;
|
||||||
|
|
||||||
fileName = evt.target.files[0].name;
|
fileName = evt.target.files[0].name;
|
||||||
|
|
||||||
Papa.parse(evt.target.files[0], {
|
Papa.parse(evt.target.files[0], {
|
||||||
header: true,
|
header: true,
|
||||||
dynamicTyping: true,
|
dynamicTyping: true,
|
||||||
@@ -105,10 +103,11 @@ function processData(data, error) {
|
|||||||
size = nodes.length;
|
size = nodes.length;
|
||||||
simulation = d3.forceSimulation();
|
simulation = d3.forceSimulation();
|
||||||
|
|
||||||
// Calculate normalization arguments and get the list of
|
// Calculate normalization parameters for distance fns
|
||||||
// properties of the nodes.
|
norm = calculateNormalization(nodes);
|
||||||
norm = calculateNormalization(nodes); // Used with distance fn
|
|
||||||
props = Object.keys(nodes[0]); // Properties to consider by distance fn
|
props = Object.keys(nodes[0]); // Properties to consider by distance fn
|
||||||
|
props.pop(); //Hide Iris index / last column from the distance function
|
||||||
|
|
||||||
COLOR_ATTRIBUTE = props[props.length-1];
|
COLOR_ATTRIBUTE = props[props.length-1];
|
||||||
|
|
||||||
var opts = document.getElementById('color_attr').options;
|
var opts = document.getElementById('color_attr').options;
|
||||||
@@ -118,19 +117,11 @@ function processData(data, error) {
|
|||||||
});
|
});
|
||||||
opts.selectedIndex = props.length-1;
|
opts.selectedIndex = props.length-1;
|
||||||
|
|
||||||
//props.pop(); //Hide Iris index / last column from distance function
|
//Put the nodes at (0,0)
|
||||||
|
|
||||||
//Put the nodes in random starting positions
|
|
||||||
//TODO Change this back
|
|
||||||
nodes.forEach(function (d) {
|
nodes.forEach(function (d) {
|
||||||
d.x = 0;
|
d.x = 0;
|
||||||
d.y = 0;
|
d.y = 0;
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
nodes.forEach(function (d) {
|
|
||||||
d.x = (Math.random()-0.5) * 100000;
|
|
||||||
d.y = (Math.random()-0.5) * 100000;
|
|
||||||
});*/
|
|
||||||
|
|
||||||
addNodesToDOM(nodes);
|
addNodesToDOM(nodes);
|
||||||
|
|
||||||
@@ -189,7 +180,6 @@ function addNodesToDOM(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ticked() {
|
function ticked() {
|
||||||
//console.log("ticked");
|
|
||||||
alreadyRanIterations++;
|
alreadyRanIterations++;
|
||||||
// If rendering is selected, then draw at every iteration.
|
// If rendering is selected, then draw at every iteration.
|
||||||
if (rendering === true) {
|
if (rendering === true) {
|
||||||
@@ -201,7 +191,7 @@ function ticked() {
|
|||||||
return d.y*MULTIPLIER;
|
return d.y*MULTIPLIER;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Emit the distribution data to allow the drawing of the bar graph
|
// Legacy: Emit the distribution data to allow the drawing of the bar graph
|
||||||
if (springForce) {
|
if (springForce) {
|
||||||
intercom.emit("passedData", simulation.force(forceName).distributionData());
|
intercom.emit("passedData", simulation.force(forceName).distributionData());
|
||||||
}
|
}
|
||||||
@@ -213,7 +203,6 @@ function ticked() {
|
|||||||
function ended() {
|
function ended() {
|
||||||
simulation.stop();
|
simulation.stop();
|
||||||
simulation.force(forceName, null);
|
simulation.force(forceName, null);
|
||||||
console.log("ended");
|
|
||||||
if (rendering !== true) { // Never drawn anything before? Now it's time.
|
if (rendering !== true) { // Never drawn anything before? Now it's time.
|
||||||
node
|
node
|
||||||
.attr("cx", function (d) {
|
.attr("cx", function (d) {
|
||||||
@@ -228,11 +217,6 @@ function ended() {
|
|||||||
// Performance time measurement
|
// Performance time measurement
|
||||||
p2 = performance.now();
|
p2 = performance.now();
|
||||||
console.log("Execution time: " + (p2 - p1));
|
console.log("Execution time: " + (p2 - p1));
|
||||||
// Do not calculate stress for data sets bigger than 100 000.
|
|
||||||
// if (nodes.length <= 100000) {
|
|
||||||
// console.log("Stress: ", simulation.force(forceName).stress());
|
|
||||||
// }
|
|
||||||
// console.log(simulation.force(forceName).nodeNeighbours());
|
|
||||||
p1 = 0;
|
p1 = 0;
|
||||||
p2 = 0;
|
p2 = 0;
|
||||||
}
|
}
|
||||||
@@ -290,7 +274,6 @@ function formatTooltip(node) {
|
|||||||
* Halt the execution.
|
* Halt the execution.
|
||||||
*/
|
*/
|
||||||
function stopSimulation() {
|
function stopSimulation() {
|
||||||
console.log("stopSimulation");
|
|
||||||
simulation.stop();
|
simulation.stop();
|
||||||
if (typeof hybridSimulation !== 'undefined') {
|
if (typeof hybridSimulation !== 'undefined') {
|
||||||
hybridSimulation.stop();
|
hybridSimulation.stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user