mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-13 16:27:33 +00:00
fix: section
This commit is contained in:
parent
df5f04a025
commit
ef2a16a387
@ -53,28 +53,18 @@ export function layout(levels: Node[][], calls: Call[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const call of calls) {
|
for (const call of calls) {
|
||||||
const sp = lineCircleIntersection(
|
const pos: any = getIntersection(
|
||||||
call.sourceObj.x,
|
|
||||||
call.sourceObj.y,
|
|
||||||
call.targetObj.x,
|
|
||||||
call.targetObj.y,
|
|
||||||
call.sourceObj.x,
|
call.sourceObj.x,
|
||||||
call.sourceObj.y,
|
call.sourceObj.y,
|
||||||
18,
|
18,
|
||||||
);
|
|
||||||
const tp = lineCircleIntersection(
|
|
||||||
call.sourceObj.x,
|
|
||||||
call.sourceObj.y,
|
|
||||||
call.targetObj.x,
|
|
||||||
call.targetObj.y,
|
|
||||||
call.targetObj.x,
|
call.targetObj.x,
|
||||||
call.targetObj.y,
|
call.targetObj.y,
|
||||||
18,
|
18,
|
||||||
);
|
) || [{}, {}];
|
||||||
call.sourceObj.ax = sp[0];
|
call.sourceObj.ax = pos[0].x;
|
||||||
call.sourceObj.ay = sp[1];
|
call.sourceObj.ay = pos[0].y;
|
||||||
call.targetObj.ax = tp[0];
|
call.targetObj.ax = pos[1].x;
|
||||||
call.targetObj.ay = tp[1];
|
call.targetObj.ay = pos[1].y;
|
||||||
}
|
}
|
||||||
const layout = {
|
const layout = {
|
||||||
width: d3.max(nodes, (n: { x: number }) => n.x) || 0 + node_width + 2 * padding,
|
width: d3.max(nodes, (n: { x: number }) => n.x) || 0 + node_width + 2 * padding,
|
||||||
@ -84,25 +74,32 @@ export function layout(levels: Node[][], calls: Call[]) {
|
|||||||
return { nodes, layout, calls };
|
return { nodes, layout, calls };
|
||||||
}
|
}
|
||||||
|
|
||||||
function lineCircleIntersection(x1: number, y1: number, x2: number, y2: number, cx: number, cy: number, r: number) {
|
function getIntersection(x1: number, y1: number, r1: number, x2: number, y2: number, r2: number) {
|
||||||
const k = (y2 - y1) / (x2 - x1);
|
const k = (y2 - y1) / (x2 - x1);
|
||||||
const b = y1 - k * x1;
|
const b = y1 - k * x1;
|
||||||
|
|
||||||
let x = 0;
|
const A = k * k + 1;
|
||||||
if (k == Infinity || k == -Infinity) {
|
const B = 2 * (k * b - k * y1 - x1);
|
||||||
x = x1;
|
const C = y1 * y1 + k * k * x1 * x1 - 2 * k * x1 * y1 - b * b - r1 * r1;
|
||||||
|
|
||||||
|
const delta = B * B - 4 * A * C;
|
||||||
|
|
||||||
|
if (delta < 0) {
|
||||||
|
return null;
|
||||||
|
} else if (delta == 0) {
|
||||||
|
const x = -B / (2 * A);
|
||||||
|
const y = k * x + b;
|
||||||
|
return { x, y };
|
||||||
} else {
|
} else {
|
||||||
x =
|
const x1 = (-B + Math.sqrt(delta)) / (2 * A);
|
||||||
(b -
|
const y1 = k * x1 + b;
|
||||||
cy +
|
|
||||||
k * cx +
|
const x2 = (-B - Math.sqrt(delta)) / (2 * A);
|
||||||
Math.sqrt(
|
const y2 = k * x2 + b;
|
||||||
Math.abs((cy - b - k * cx) * (cy - b - k * cx) - (1 + k * k) * (cx * cx - 2 * k * cx * cy + cy * cy - r * r)),
|
|
||||||
)) /
|
return [
|
||||||
(1 + k * k);
|
{ x: x1, y: y1 },
|
||||||
|
{ x: x2, y: y2 },
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
const y = k * x + b;
|
|
||||||
|
|
||||||
return [x, y];
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user