update graph

This commit is contained in:
Fine 2022-08-22 11:35:19 +08:00
parent 710306708b
commit d3a42eefbc
2 changed files with 46 additions and 4 deletions

View File

@ -72,6 +72,48 @@ export const networkProfilingStore = defineStore({
this.activeMetricIndex = index;
},
setTopology(data: { nodes: ProcessNode[]; calls: Call[] }) {
data.nodes = [
...data.nodes,
{
id: "8fb699b42bddbc2800f48c620db3b14388214f057822aa16a2eef7e95f111111",
isReal: true,
name: "python111",
serviceId: "YWdlbnRsZXNzOjpyZWNvbW1lbmRhdGl111==.1",
serviceInstanceId:
"YWdlbnRsZXNzOjpyZWNvbW1lbmRhdGlvbg==.1_cmVjb21tZW5kYXRpb24tZGVwbG95bWVudC01NzQ3Yzk3NmQ5LWx1111",
serviceInstanceName: "recommendation-deployment-5747c976d9-l123",
serviceName: "agentless::recommendation123",
},
{
id: "8fb699b42bddbc2800f48c620db3b14388214f057822aa16a2eef7e95f222222",
isReal: true,
name: "python222",
serviceId: "YWdlbnRsZXNzOjpyZWNvbW1lbmRhdGl111==.1",
serviceInstanceId:
"YWdlbnRsZXNzOjpyZWNvbW1lbmRhdGlvbg==.1_cmVjb21tZW5kYXRpb24tZGVwbG95bWVudC01NzQ3Yzk3NmQ5LWx11114",
serviceInstanceName: "recommendation-deployment-5747c976d9-l1234",
serviceName: "agentless::recommendation1234",
},
];
data.calls = [
...data.calls,
{
detectPoints: ["SERVER"],
id: "689f0e6178a740ef33a83349b79866dae5ab1fcbb2077da06e44ee511a7769e7-8fb699b42bddbc2800f48c620db3b14388214f057822aa16a2eef7e95f222222",
source:
"689f0e6178a740ef33a83349b79866dae5ab1fcbb2077da06e44ee511a7769e7",
target:
"8fb699b42bddbc2800f48c620db3b14388214f057822aa16a2eef7e95f222222",
},
{
detectPoints: ["SERVER"],
id: "689f0e6178a740ef33a83349b79866dae5ab1fcbb2077da06e44ee511a7769e7-8fb699b42bddbc2800f48c620db3b14388214f057822aa16a2eef7e95f111111",
source:
"689f0e6178a740ef33a83349b79866dae5ab1fcbb2077da06e44ee511a7769e7",
target:
"8fb699b42bddbc2800f48c620db3b14388214f057822aa16a2eef7e95f111111",
},
];
const obj = {} as any;
let calls = (data.calls || []).reduce((prev: Call[], next: Call) => {
if (!obj[next.id]) {

View File

@ -107,10 +107,10 @@ function drawGraph() {
const outNodes = networkProfilingStore.nodes.filter(
(d: ProcessNode) => d.serviceInstanceId !== selectorStore.currentPod.id
);
if (!outNodes.length) {
diff.value[0] = (dom.width - radius * 2) / 2 + radius;
if (outNodes.length) {
diff.value[0] = (dom.width - radius * 3) / 2 + radius;
} else {
diff.value[0] = (dom.width - radius * 4) / 2 + radius;
diff.value[0] = (dom.width - radius * 2) / 2 + radius;
}
graph.value = svg.value
.append("g")
@ -273,7 +273,7 @@ function createLayout() {
const pos = getArcPoint(angle, r); // angle is [-120, 120]
outNodes[v].x = pos[0];
outNodes[v].y = pos[1];
angle = angle + 10;
angle = angle + 20;
if (angle * (v + 1) > 120) {
angle = -10;
}