From 2ef3f5f9e81ddbd05c2f55957cde5c09b4e19aae Mon Sep 17 00:00:00 2001 From: Kia Lam Date: Thu, 7 Jul 2022 16:04:25 -0700 Subject: [PATCH] Remove external script call to D3.js. --- awx/ui/package.json | 1 - awx/ui/src/util/simulationWorker.js | 21 +++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/awx/ui/package.json b/awx/ui/package.json index 628aceef96..62bb01504c 100644 --- a/awx/ui/package.json +++ b/awx/ui/package.json @@ -1,6 +1,5 @@ { "name": "ui", - "homepage": ".", "private": true, "engines": { "node": ">=16.13.1" diff --git a/awx/ui/src/util/simulationWorker.js b/awx/ui/src/util/simulationWorker.js index d743e2e76c..dcaa83dc69 100644 --- a/awx/ui/src/util/simulationWorker.js +++ b/awx/ui/src/util/simulationWorker.js @@ -1,21 +1,22 @@ -/* eslint-disable no-undef */ -importScripts('https://d3js.org/d3-collection.v1.min.js'); -importScripts('https://d3js.org/d3-dispatch.v1.min.js'); -importScripts('https://d3js.org/d3-quadtree.v1.min.js'); -importScripts('https://d3js.org/d3-timer.v1.min.js'); -importScripts('https://d3js.org/d3-force.v1.min.js'); +import * as d3 from 'd3'; +import { MESH_FORCE_LAYOUT } from '../screens/TopologyView/constants'; onmessage = function calculateLayout({ data: { nodes, links } }) { const simulation = d3 .forceSimulation(nodes) - .force('charge', d3.forceManyBody(15).strength(-50)) + .force( + 'charge', + d3 + .forceManyBody(MESH_FORCE_LAYOUT.defaultForceBody) + .strength(MESH_FORCE_LAYOUT.defaultForceStrength) + ) .force( 'link', d3.forceLink(links).id((d) => d.hostname) ) - .force('collide', d3.forceCollide(62)) - .force('forceX', d3.forceX(0)) - .force('forceY', d3.forceY(0)) + .force('collide', d3.forceCollide(MESH_FORCE_LAYOUT.defaultCollisionFactor)) + .force('forceX', d3.forceX(MESH_FORCE_LAYOUT.defaultForceX)) + .force('forceY', d3.forceY(MESH_FORCE_LAYOUT.defaultForceY)) .stop(); for (