From bedcbd80ae4788edd131e27f486e32bc544b9a33 Mon Sep 17 00:00:00 2001 From: "shiwu.wyy" Date: Fri, 19 Jul 2019 11:48:37 +0800 Subject: [PATCH] fix: redundant code --- demos/radial-interact-layout.html | 17 ++++++----------- plugins/radial/index.js | 7 +------ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/demos/radial-interact-layout.html b/demos/radial-interact-layout.html index 35e379bf30..b320e695b7 100644 --- a/demos/radial-interact-layout.html +++ b/demos/radial-interact-layout.html @@ -3300,9 +3300,7 @@ maxIteration: 200, focusNode, unitRadius: mainUnitRadius, - linkDistance: 230, - nodeSize: 20, - nonOverlap: true + linkDistance: 250 }); G6.registerBehavior('click-add-node', { @@ -3376,7 +3374,8 @@ const maxDegree = 4; // the max degree about foces(clicked) node in the original data const oMaxDegree = 3; - const unitRadius = 60; + const unitRadius = 40; + const focusNodeId = "2"; // re-place the clicked node far away the exisiting items // along the radius from center node to it const vx = itemModel.x - focusNode.x; @@ -3389,11 +3388,9 @@ const subRadialLayout = new Radial({ center: [ itemModel.x, itemModel.y ], maxIteration: 200, - focusNode: itemModel, + focusNode: "2", unitRadius, - linkDistance: 120, - nodeSize: 20, - nonOverlap: true + linkDistance: 180 }); graph.addPlugin(subRadialLayout); // only layout the newly added part around the clicked node @@ -3401,8 +3398,6 @@ {'nodes': newNodeModels, 'edges': newEdgeModels} ); - - focusNode = itemModel; graph.changeData({"nodes": allNodeModels, "edges": allEdgeModels}); } }); @@ -3444,7 +3439,7 @@ graph.data({ nodes: data_m.nodes, edges: data_m.edges.map((edge, i) => { edge.id = 'edge' + i; return Object.assign({}, edge); - }) }); + }) }); RadialLayoutPlugin.layout(data_m); graph.render(); diff --git a/plugins/radial/index.js b/plugins/radial/index.js index 87dc596d4e..093aaa161b 100644 --- a/plugins/radial/index.js +++ b/plugins/radial/index.js @@ -198,8 +198,6 @@ class Radial extends Base { const self = this; const vparam = 1 - param; const focusIndex = self.get('focusIndex'); - const nonOverlap = self.get('nonOverlap'); - const nodeRadius = self.get('nodeRadius'); positions.forEach((v, i) => { // v const originDis = Util.getEDistance(v, [ 0, 0 ]); const reciODis = originDis === 0 ? 0 : 1 / originDis; @@ -213,10 +211,7 @@ class Radial extends Base { // the euclidean distance between v and u const edis = Util.getEDistance(v, u); const reciEdis = edis === 0 ? 0 : 1 / edis; - let idealDis = D[j][i]; - if (nonOverlap && radii[i] === radii[j] && param < 0.2 && edis < (2 * nodeRadius)) { - idealDis += (nodeRadius * 2); - } + const idealDis = D[j][i]; // same for x and y denominator += W[i][j]; // x