Pivot near neighbour finding working
This commit is contained in:
@@ -63,6 +63,13 @@ var MULTIPLIER = 50,
|
||||
// Create a color scheme for a range of numbers.
|
||||
var color = d3.scaleOrdinal(d3.schemeCategory10);
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
distanceFunction = calculateDistance;
|
||||
d3.select('#startSimulation').on('click', startHybridSimulation);
|
||||
$("#HLParameters").show();
|
||||
});
|
||||
|
||||
/**
|
||||
* Parse the data from the provided csv file using Papa Parse library
|
||||
* @param {file} evt - csv file.
|
||||
@@ -112,10 +119,16 @@ function processData(data, error) {
|
||||
props.pop(); //Hide Iris index / last column from distance function
|
||||
|
||||
//Put the nodes in random starting positions
|
||||
//TODO Change this back
|
||||
nodes.forEach(function (d) {
|
||||
d.x = 0;
|
||||
d.y = 0;
|
||||
});
|
||||
/*
|
||||
nodes.forEach(function (d) {
|
||||
d.x = (Math.random()-0.5) * 100000;
|
||||
d.y = (Math.random()-0.5) * 100000;
|
||||
});
|
||||
});*/
|
||||
|
||||
addNodesToDOM(nodes);
|
||||
|
||||
@@ -139,7 +152,7 @@ function addNodesToDOM(data) {
|
||||
// it is a CLASS property).
|
||||
.attr("fill", function (d) {
|
||||
return color(d[COLOR_ATTRIBUTE]);
|
||||
})
|
||||
})/*
|
||||
.on("mouseover", function (d) {
|
||||
div.transition()
|
||||
.duration(200)
|
||||
@@ -158,6 +171,7 @@ function addNodesToDOM(data) {
|
||||
node.attr("opacity", 1);
|
||||
})
|
||||
.on("click", function (d) {
|
||||
console.log("click", clickedIndex);
|
||||
if (clickedIndex !== d.index) {
|
||||
if (springForce) {
|
||||
highlightNeighbours(Array.from(simulation.force(forceName).nodeNeighbours(d.index).keys()));
|
||||
@@ -167,12 +181,13 @@ function addNodesToDOM(data) {
|
||||
node.attr("r", NODE_SIZE).attr("stroke-width", 0);
|
||||
clickedIndex = -1;
|
||||
}
|
||||
});
|
||||
})*/;
|
||||
if (selectedData)
|
||||
unSelectNodes(selectedData);
|
||||
}
|
||||
|
||||
function ticked() {
|
||||
console.log("ticked");
|
||||
// If rendering is selected, then draw at every iteration.
|
||||
if (rendering === true) {
|
||||
node // Each sub-circle in the SVG, update cx and cy
|
||||
@@ -190,6 +205,7 @@ function ticked() {
|
||||
}
|
||||
|
||||
function ended() {
|
||||
console.log("ended");
|
||||
if (rendering !== true) { // Never drawn anything before? Now it's time.
|
||||
node
|
||||
.attr("cx", function (d) {
|
||||
@@ -215,6 +231,7 @@ function ended() {
|
||||
}
|
||||
|
||||
function brushEnded() {
|
||||
console.log("brushEnded");
|
||||
var s = d3.event.selection,
|
||||
results = [];
|
||||
|
||||
@@ -248,6 +265,7 @@ function brushEnded() {
|
||||
* @param {*} node
|
||||
*/
|
||||
function formatTooltip(node) {
|
||||
console.log("formatTooltip", node);
|
||||
var textString = "",
|
||||
temp = "";
|
||||
|
||||
@@ -266,6 +284,7 @@ function formatTooltip(node) {
|
||||
* Halt the execution.
|
||||
*/
|
||||
function stopSimulation() {
|
||||
console.log("stopSimulation");
|
||||
simulation.stop();
|
||||
if (typeof hybridSimulation !== 'undefined') {
|
||||
hybridSimulation.stop();
|
||||
@@ -278,6 +297,7 @@ function stopSimulation() {
|
||||
* @return {number} the mean of the array.
|
||||
*/
|
||||
function getAverage(array) {
|
||||
console.log("getAverage", array);
|
||||
var total = 0;
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
total += array[i];
|
||||
@@ -290,7 +310,7 @@ function getAverage(array) {
|
||||
* @param {*} data
|
||||
*/
|
||||
function unSelectNodes(data) {
|
||||
|
||||
console.log("unSelectNodes", data);
|
||||
selectedData = data;
|
||||
if (fileName === data.name && nodes) {
|
||||
node
|
||||
@@ -348,7 +368,7 @@ function colorToAttribute() {
|
||||
|
||||
/**
|
||||
* Update the distance range.
|
||||
*/
|
||||
|
||||
function updateDistanceRange() {
|
||||
if (springForce) {
|
||||
simulation.force(forceName).distanceRange(SELECTED_DISTANCE);
|
||||
@@ -380,7 +400,7 @@ function pauseUnPause() {
|
||||
* @param {*} dataNodes
|
||||
* @param {*} properties
|
||||
* @param {*} normalization
|
||||
*/
|
||||
|
||||
function calculateAverageDistance(dataNodes, properties, normalization) {
|
||||
var sum = 0,
|
||||
n = nodes.length;
|
||||
@@ -397,4 +417,4 @@ function calculateAverageDistance(dataNodes, properties, normalization) {
|
||||
}
|
||||
|
||||
return sum / n;
|
||||
}
|
||||
}*/
|
||||
|
||||
Reference in New Issue
Block a user