From 249dde739e6cc8f4c136528aacbd5d63e5fdcb15 Mon Sep 17 00:00:00 2001 From: Zipexpo Date: Wed, 11 Mar 2020 19:05:39 -0500 Subject: [PATCH 1/2] init --- BioRadar/index.html | 2 + BioRadar/network.html | 116 ++++++++++++++++++++++++++++++++++++ BioRadar/src/script/main.js | 64 ++++++++++++++++++++ 3 files changed, 182 insertions(+) create mode 100644 BioRadar/network.html diff --git a/BioRadar/index.html b/BioRadar/index.html index 633e2663..ec461a49 100644 --- a/BioRadar/index.html +++ b/BioRadar/index.html @@ -829,6 +829,8 @@
saving
+ +
diff --git a/BioRadar/network.html b/BioRadar/network.html new file mode 100644 index 00000000..b862de0c --- /dev/null +++ b/BioRadar/network.html @@ -0,0 +1,116 @@ + + + + + Title + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BioRadar/src/script/main.js b/BioRadar/src/script/main.js index 21ce666b..27c68ede 100644 --- a/BioRadar/src/script/main.js +++ b/BioRadar/src/script/main.js @@ -412,8 +412,72 @@ function main() { // MetricController.data(data.result.arr).drawSummary(data.result.hindex); init = false; firstTime = false; + + network() + // request(); } +function network(){ + let dataTemp = handle_data_model(tsnedata); + let dataNest = d3.nest().key(d=>d.name).rollup(d=>(temp = d[1].map((e,i)=>e-d[0][i]>0?1:(e-d[0][i]<0?-1:0)),temp.cluster=d[0].cluster===d[1].cluster?d[0].cluster:-1,temp)).object(dataTemp); + let data ={ + links:[], + nodes:_.keys(dataNest).map(d=>({id:d,group:1})) + } + + for (let i= 0; i< data.nodes.length;i++){ + for (let j= i+1; j< data.nodes.length;j++) { + let dis = distance(dataNest[data.nodes[i].id],dataNest[data.nodes[j].id])<2; + if(dis<2){ + data.links.push({source: data.nodes[i].id, target: data.nodes[j].id, value: 1/dis}) + } + } + } + console.log(JSON.stringify(data)); + const links = data.links.map(d => Object.create(d)); + const nodes = data.nodes.map(d => Object.create(d)); + + const simulation = d3.forceSimulation(nodes) + .force("link", d3.forceLink(links).id(d => d.id)) + .force("charge", d3.forceManyBody()) + .force("center", d3.forceCenter(width / 2, height / 2)); + + const svg = d3.select("svg#network") + .attr("viewBox", [0, 0, width, height]); + + const link = svg.append("g") + .attr("stroke", "#999") + .attr("stroke-opacity", 0.6) + .selectAll("line") + .data(links) + .join("line") + .attr("stroke-width", d => Math.sqrt(d.value)); + + const node = svg.append("g") + .attr("stroke", "#fff") + .attr("stroke-width", 1.5) + .selectAll("circle") + .data(nodes) + .join("circle") + .attr("r", 5) + .attr("fill", color) + .call(drag(simulation)); + + node.append("title") + .text(d => d.id); + + simulation.on("tick", () => { + link + .attr("x1", d => d.source.x) + .attr("y1", d => d.source.y) + .attr("x2", d => d.target.x) + .attr("y2", d => d.target.y); + + node + .attr("cx", d => d.x) + .attr("cy", d => d.y); + }); +} var currentlastIndex; var speedup= 0; From 8089d2e562223acb496cdeb731a10fd0d0969f5a Mon Sep 17 00:00:00 2001 From: Zipexpo Date: Thu, 12 Mar 2020 17:23:57 -0500 Subject: [PATCH 2/2] Update main.js --- BioRadar/src/script/main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BioRadar/src/script/main.js b/BioRadar/src/script/main.js index 27c68ede..5dabde5a 100644 --- a/BioRadar/src/script/main.js +++ b/BioRadar/src/script/main.js @@ -424,14 +424,15 @@ function network(){ links:[], nodes:_.keys(dataNest).map(d=>({id:d,group:1})) } - + let unqiueG = d3.nest().key(d=>d.value.join('')).entries(unqiueG); for (let i= 0; i< data.nodes.length;i++){ for (let j= i+1; j< data.nodes.length;j++) { - let dis = distance(dataNest[data.nodes[i].id],dataNest[data.nodes[j].id])<2; + let dis = distance(dataNest[data.nodes[i].id],dataNest[data.nodes[j].id]); if(dis<2){ data.links.push({source: data.nodes[i].id, target: data.nodes[j].id, value: 1/dis}) } } + console.log(i); } console.log(JSON.stringify(data)); const links = data.links.map(d => Object.create(d)); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy