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