Skip to content
Snippets Groups Projects
Commit cc13c31c authored by Jean-Clement Gallardo's avatar Jean-Clement Gallardo
Browse files

Add check nodes positions functions -> stop or launch algo for reload possibility

parent 9d7eaf61
No related branches found
No related tags found
No related merge requests found
......@@ -31,11 +31,15 @@ const mappings = {
conditions: ['cond1', 'cond2'],
data: "nodeIdentifier\tcond1\tcond2\nA\t12\t10\nR1\t24\t30\nB\t48\t55\nR2\t-1\t-2\nC\t42\t67"
}
}
} as {[key: string]: any}
function loadData() {
boolSwitch.value = false;
importNetworkFromURL("/large_demo_dataset.json", networkTmp, networkStyle);
mappings["CA3"] = {
conditions: ['cond1', 'cond2'],
data: "nodeIdentifier\tcond1\tcond2\nA\t12\t10\nR1\t24\t30\nB\t48\t55\nR2\t-1\t-2\nC\t42\t67"
}
}
function changeData() {
......
......@@ -138,19 +138,17 @@ export function initialiseGlobalNetwork(newNetwork: Network, allowAutoAlgo: bool
network.value = newNetwork;
callbackFunction(network, networkStyle, loading);
resetSimulation();
if (allowAutoAlgo) {
const algoAproval = nodesPosDetection(network.value.nodes);
if (allowAutoAlgo && algoAproval) {
if (Object.keys(network.value.nodes).length > 500) {
createClusterForceLayout(network.value);
setTimeout(() => {
rescaleNetwork();
}, 500)
} else {
forceLayoutManagement();
setTimeout(() => {
rescaleNetwork();
}, 500)
}
}
setTimeout(() => {
rescaleNetwork();
}, 500);
}
export function selectNode(value: {event: MouseEvent, node: Node}): void {
......@@ -159,4 +157,16 @@ export function selectNode(value: {event: MouseEvent, node: Node}): void {
export function openContextMenu(value: {event: MouseEvent, node: Node}) {
UseContextMenu.showContextMenu(value.event, value.node.id);
}
function nodesPosDetection(nodes: {[key: string]: Node}): boolean {
let allowAlgo = false;
Object.keys(nodes).forEach((nodeID: string) => {
if (nodes[nodeID].x === 0 && nodes[nodeID].y === 0) {
allowAlgo = true;
}
});
return allowAlgo;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment