fixed some label transform for htmlLabels false

This commit is contained in:
saurabhg772244
2024-08-19 20:21:42 +05:30
parent e2f3041aa2
commit 9c5a8f7ef1
9 changed files with 18 additions and 9 deletions

View File

@@ -57,7 +57,7 @@ export const dividedRect = async (parent: SVGAElement, node: Node) => {
label.attr(
'transform',
`translate(${x + (node.padding ?? 0) / 2}, ${y + rectOffset + (node.padding ?? 0) / 2})`
`translate(${x + (node.padding ?? 0) / 2 - (bbox.x - (bbox.left ?? 0))}, ${y + rectOffset + (node.padding ?? 0) / 2 - 4 * (bbox.y - (bbox.top ?? 0))})`
);
updateNodeBounds(node, polygon);

View File

@@ -53,7 +53,10 @@ export const flippedTriangle = async (parent: SVGAElement, node: Node): Promise<
updateNodeBounds(node, flippedTriangle);
label.attr('transform', `translate(${-bbox.width / 2}, ${-h / 2})`);
label.attr(
'transform',
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${-h / 2 + 4 * (bbox.y - (bbox.top ?? 0))})`
);
node.intersect = function (point) {
log.info('Triangle intersect', node, points, point);

View File

@@ -52,7 +52,7 @@ export const halfRoundedRectangle = async (parent: SVGAElement, node: Node) => {
polygon.attr('transform', `translate(${-w / 2 - h / 4}, ${-h / 2})`);
label.attr(
'transform',
`translate(${-w / 2 + (node.padding ?? 0) - h / 4}, ${-h / 2 + (node.padding ?? 0)})`
`translate(${-w / 2 + (node.padding ?? 0) - h / 4 - (bbox.x - (bbox.left ?? 0))}, ${-h / 2 + (node.padding ?? 0) - 4 * (bbox.y - (bbox.top ?? 0))})`
);
updateNodeBounds(node, polygon);

View File

@@ -65,7 +65,10 @@ export const linedCylinder = async (parent: SVGAElement, node: Node) => {
updateNodeBounds(node, cylinder);
label.attr('transform', `translate(${-bbox.width / 2}, ${h / 2 - bbox.height + outerOffset})`);
label.attr(
'transform',
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${h / 2 - bbox.height + outerOffset - 4 * (bbox.y - (bbox.top ?? 0))})`
);
node.intersect = function (point) {
const pos = intersect.rect(node, point);

View File

@@ -71,7 +71,7 @@ export const multiRect = async (parent: SVGAElement, node: Node) => {
label.attr(
'transform',
`translate(${-(bbox.width / 2) - rectOffset}, ${-(bbox.height / 2) + rectOffset})`
`translate(${-(bbox.width / 2) - rectOffset - (bbox.x - (bbox.left ?? 0))}, ${-(bbox.height / 2) + rectOffset - 4 * (bbox.y - (bbox.top ?? 0))})`
);
updateNodeBounds(node, multiRect);

View File

@@ -51,7 +51,7 @@ export const slopedRect = async (parent: SVGAElement, node: Node) => {
polygon.attr('transform', `translate(0, ${h / 4})`);
label.attr(
'transform',
`translate(${-w / 2 + (node.padding ?? 0)}, ${-h / 4 + (node.padding ?? 0)})`
`translate(${-w / 2 + (node.padding ?? 0) - (bbox.x - (bbox.left ?? 0))}, ${-h / 4 + (node.padding ?? 0) - 4 * (bbox.y - (bbox.top ?? 0))})`
);
updateNodeBounds(node, polygon);

View File

@@ -53,7 +53,10 @@ export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAEle
updateNodeBounds(node, polygon);
label.attr('transform', `translate(${-bbox.width / 2}, ${h / 2 - bbox.height})`);
label.attr(
'transform',
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${h / 2 - bbox.height - 4 * (bbox.y - (bbox.top ?? 0))})`
);
node.intersect = function (point) {
log.info('Triangle intersect', node, points, point);

View File

@@ -54,7 +54,7 @@ export const waveEdgedRectangle = async (parent: SVGAElement, node: Node) => {
waveEdgeRect.attr('transform', `translate(0,${-waveAmplitude / 2})`);
label.attr(
'transform',
`translate(${-w / 2 + (node.padding ?? 0)},${-h / 2 + (node.padding ?? 0) - waveAmplitude / 2})`
`translate(${-w / 2 + (node.padding ?? 0) - (bbox.x - (bbox.left ?? 0))},${-h / 2 + (node.padding ?? 0) - waveAmplitude / 2 - 4 * (bbox.y - (bbox.top ?? 0))})`
);
updateNodeBounds(node, waveEdgeRect);

View File

@@ -68,7 +68,7 @@ export const windowPane = async (parent: SVGAElement, node: Node) => {
label.attr(
'transform',
`translate(${-(bbox.width / 2) + rectOffset / 2}, ${-(bbox.height / 2) + rectOffset / 2})`
`translate(${-(bbox.width / 2) + rectOffset / 2 - (bbox.x - (bbox.left ?? 0))}, ${-(bbox.height / 2) + rectOffset / 2 - 4 * (bbox.y - (bbox.top ?? 0))})`
);
updateNodeBounds(node, windowPane);