How to use the @antv/g6.Util.getEDistance function in @antv/g6

To help you get started, we’ve selected a few @antv/g6 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antvis / G6 / plugins / radial / index.js View on Github external
positions.forEach((u, j) => { // u
        if (i === j) return;
        // if (j === focusIndex) return;
        // the euclidean distance between v and u
        const edis = Util.getEDistance(v, u);
        const reciEdis = edis === 0 ? 0 : 1 / edis;
        const idealDis = D[j][i];
        // same for x and y
        denominator += W[i][j];
        // x
        xMolecule += W[i][j] * (u[0] + idealDis * (v[0] - u[0]) * reciEdis);
        // y
        yMolecule += W[i][j] * (u[1] + idealDis * (v[1] - u[1]) * reciEdis);
      });
      const reciR = radii[i] === 0 ? 0 : 1 / radii[i];
github antvis / G6 / plugins / radial / index.js View on Github external
positions.forEach((v, i) => { // v
      const originDis = Util.getEDistance(v, [ 0, 0 ]);
      const reciODis = originDis === 0 ? 0 : 1 / originDis;
      if (i === focusIndex) return;
      let xMolecule = 0;
      let yMolecule = 0;
      let denominator = 0;
      positions.forEach((u, j) => { // u
        if (i === j) return;
        // if (j === focusIndex) return;
        // the euclidean distance between v and u
        const edis = Util.getEDistance(v, u);
        const reciEdis = edis === 0 ? 0 : 1 / edis;
        const idealDis = D[j][i];
        // same for x and y
        denominator += W[i][j];
        // x
        xMolecule += W[i][j] * (u[0] + idealDis * (v[0] - u[0]) * reciEdis);