From e34641febca816d71e0d4ed18f4244604fa5f4d0 Mon Sep 17 00:00:00 2001 From: xiaoluoHe Date: Wed, 25 Dec 2024 17:00:06 +0800 Subject: [PATCH 1/3] feat: support label for 3d arc --- packages/vrender-components/src/label/arc.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/vrender-components/src/label/arc.ts b/packages/vrender-components/src/label/arc.ts index f935fd928..5b71b46ee 100644 --- a/packages/vrender-components/src/label/arc.ts +++ b/packages/vrender-components/src/label/arc.ts @@ -29,6 +29,7 @@ import { isFunction } from '@visactor/vutils'; export class ArcInfo { key!: string; refDatum!: any; + refArc!: IArc; /** * 绘图区圆弧中点 */ @@ -239,6 +240,14 @@ export class ArcLabel extends LabelBase { basedArc.labelLimit ?? (labels[i].attribute as ITextAttribute).maxLineWidth; } + if (basedArc.refArc && basedArc.refArc.type === 'arc3d') { + (labelAttribute as any).anchor3d = [ + basedArc.circleCenter.x - labelAttribute.x, + basedArc.circleCenter.y - labelAttribute.y + ]; + (labelAttribute as any).beta = basedArc.refArc.attribute.beta; + } + labels[i].setAttributes(labelAttribute); } } @@ -290,7 +299,7 @@ export class ArcLabel extends LabelBase { graphicAttribute.outerRadius, center ); - + arc.refArc = currentMark; arc.pointA = polarToCartesian( center as IPoint, this.computeDatumRadius(center.x * 2, center.y * 2, graphicAttribute.outerRadius), @@ -1006,6 +1015,14 @@ export class ArcLabel extends LabelBase { curveType: 'basis' }); } + + if (baseMark.type === 'arc3d' && baseMark) { + const { beta, x, y } = baseMark.attribute; + lineGraphic.setAttributes({ + beta, + anchor3d: [x, y] + }); + } } return lineGraphic; From 61c02e6603ad95e34ee7657d88d430efef1952b5 Mon Sep 17 00:00:00 2001 From: xiaoluoHe Date: Wed, 25 Dec 2024 17:02:22 +0800 Subject: [PATCH 2/3] docs: add changelog --- .../fix-3d-arc-label_2024-12-25-09-02.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@visactor/vrender-components/fix-3d-arc-label_2024-12-25-09-02.json diff --git a/common/changes/@visactor/vrender-components/fix-3d-arc-label_2024-12-25-09-02.json b/common/changes/@visactor/vrender-components/fix-3d-arc-label_2024-12-25-09-02.json new file mode 100644 index 000000000..c198bcc2a --- /dev/null +++ b/common/changes/@visactor/vrender-components/fix-3d-arc-label_2024-12-25-09-02.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@visactor/vrender-components", + "comment": "fix: handle the additional logic of 3d arc label layout", + "type": "none" + } + ], + "packageName": "@visactor/vrender-components" +} \ No newline at end of file From 48bab12e586a413a469b1c68f86d5f8c309bbba9 Mon Sep 17 00:00:00 2001 From: xiaoluoHe Date: Wed, 25 Dec 2024 17:04:53 +0800 Subject: [PATCH 3/3] fix: fix type error --- packages/vrender-components/src/label/arc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vrender-components/src/label/arc.ts b/packages/vrender-components/src/label/arc.ts index 5b71b46ee..3d0879474 100644 --- a/packages/vrender-components/src/label/arc.ts +++ b/packages/vrender-components/src/label/arc.ts @@ -299,7 +299,7 @@ export class ArcLabel extends LabelBase { graphicAttribute.outerRadius, center ); - arc.refArc = currentMark; + arc.refArc = currentMark as IArc; arc.pointA = polarToCartesian( center as IPoint, this.computeDatumRadius(center.x * 2, center.y * 2, graphicAttribute.outerRadius),