diff --git a/src/store/modules/network-profiling.ts b/src/store/modules/network-profiling.ts index 0b181111..2c45208c 100644 --- a/src/store/modules/network-profiling.ts +++ b/src/store/modules/network-profiling.ts @@ -109,7 +109,6 @@ export const networkProfilingStore = defineStore({ }, []); this.calls = calls; this.nodes = data.nodes; - console.log(calls); }, async createNetworkTask(param: { serviceId: string; diff --git a/src/views/dashboard/related/network-profiling/components/Graph/linkProcess.ts b/src/views/dashboard/related/network-profiling/components/Graph/linkProcess.ts index 9e0b7da4..26c94e4c 100644 --- a/src/views/dashboard/related/network-profiling/components/Graph/linkProcess.ts +++ b/src/views/dashboard/related/network-profiling/components/Graph/linkProcess.ts @@ -17,64 +17,6 @@ import icons from "@/assets/img/icons"; import { Call } from "@/types/topology"; -export const linkElement = (graph: any) => { - const linkEnter = graph - .append("path") - .attr("class", "topo-call") - .attr("marker-end", "url(#arrow)") - .attr("stroke", "#97B0F8") - .attr("d", (d: Call) => linkPath(d)); - return linkEnter; -}; -export const anchorElement = (graph: any, funcs: any, tip: any) => { - const linkEnter = graph - .append("g") - .attr("class", "topo-line-anchor") - .on("mouseover", function (event: unknown, d: unknown) { - tip.html(funcs.tipHtml).show(d, this); - }) - .on("mouseout", function () { - tip.hide(this); - }) - .on("click", (event: unknown, d: unknown) => { - funcs.handleLinkClick(event, d); - }); - - linkEnter - .append("image") - .attr("width", 15) - .attr("height", 15) - .attr("x", (d: Call) => { - const p = getMidpoint(d); - return p[0] - 8; - }) - .attr("y", (d: Call) => { - const p = getMidpoint(d); - return p[1] - 13; - }) - .attr("xlink:href", (d: Call) => { - return getAnchor(d); - }); - return linkEnter; -}; -export const arrowMarker = (graph: any) => { - const defs = graph.append("defs"); - const arrow = defs - .append("marker") - .attr("id", "arrow") - .attr("class", "topo-line-arrow") - .attr("markerUnits", "strokeWidth") - .attr("markerWidth", "8") - .attr("markerHeight", "8") - .attr("viewBox", "0 0 12 12") - .attr("refX", "10") - .attr("refY", "6") - .attr("orient", "auto"); - const arrowPath = "M2,2 L10,6 L2,10 L6,6 L2,2"; - - arrow.append("path").attr("d", arrowPath).attr("fill", "#97B0F8"); - return arrow; -}; // Control Point coordinates of quadratic Bezier curve function computeControlPoint(ps: number[], pe: number[], arc = 0.5) { const deltaX = pe[0] - ps[0]; @@ -106,13 +48,18 @@ function quadraticBezier( return [x, y]; } export function getMidpoint(d: Call) { + if (isNaN(d.source.x) || isNaN(d.source.y)) { + return [0, 0]; + } + if (isNaN(d.target.x) || isNaN(d.target.y)) { + return [0, 0]; + } const controlPos = computeControlPoint( [d.source.x, d.source.y], [d.target.x, d.target.y], 0.5 ); if (d.lowerArc) { - console.log(true); controlPos[1] = -controlPos[1]; } const p = quadraticBezier( @@ -124,6 +71,12 @@ export function getMidpoint(d: Call) { return p; } export function linkPath(d: Call) { + if (isNaN(d.source.x) || isNaN(d.source.y)) { + return; + } + if (isNaN(d.target.x) || isNaN(d.target.y)) { + return; + } const controlPos = computeControlPoint( [d.source.x, d.source.y - 5], [d.target.x, d.target.y - 5], diff --git a/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue b/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue index 428cfee9..5f8dfed0 100644 --- a/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue +++ b/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue @@ -33,7 +33,13 @@ limitations under the License. --> - + v-for="(call, index) in networkProfilingStore.calls" :key="index" class="topo-call" - markerEnd="url(#arrow)" + marker-end="url(#arrow)" stroke="#97B0F8" :d="linkPath(call)" /> @@ -71,16 +77,13 @@ limitations under the License. --> height="15" :x="getMidpoint(call)[0] - 8" :y="getMidpoint(call)[1] - 13" + @click="handleLinkClick($event, call)" /> - + +
test tooltip