Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 3d arc label #1655

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"
}
19 changes: 18 additions & 1 deletion packages/vrender-components/src/label/arc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { isFunction } from '@visactor/vutils';
export class ArcInfo {
key!: string;
refDatum!: any;
refArc!: IArc;
/**
* 绘图区圆弧中点
*/
Expand Down Expand Up @@ -239,6 +240,14 @@ export class ArcLabel extends LabelBase<ArcLabelAttrs> {
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);
}
}
Expand Down Expand Up @@ -290,7 +299,7 @@ export class ArcLabel extends LabelBase<ArcLabelAttrs> {
graphicAttribute.outerRadius,
center
);

arc.refArc = currentMark as IArc;
arc.pointA = polarToCartesian(
center as IPoint,
this.computeDatumRadius(center.x * 2, center.y * 2, graphicAttribute.outerRadius),
Expand Down Expand Up @@ -1006,6 +1015,14 @@ export class ArcLabel extends LabelBase<ArcLabelAttrs> {
curveType: 'basis'
});
}

if (baseMark.type === 'arc3d' && baseMark) {
const { beta, x, y } = baseMark.attribute;
lineGraphic.setAttributes({
beta,
anchor3d: [x, y]
});
}
}

return lineGraphic;
Expand Down
Loading