From bdae17e817e393dd73b1441593a4879ca80d926f Mon Sep 17 00:00:00 2001 From: xiaoluoHe Date: Wed, 25 Dec 2024 10:41:02 +0800 Subject: [PATCH] feat: support polygon crosshair for angleAxis in polar coordinate --- .../crosshair-common/crosshair-line.md | 3 ++- .../crosshair-common/crosshair-line.md | 2 +- .../vchart/src/component/crosshair/base.ts | 2 +- .../src/component/crosshair/interface/spec.ts | 5 ++++ .../vchart/src/component/crosshair/polar.ts | 24 +++++++++++++++++-- 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/docs/assets/option/en/component/crosshair-common/crosshair-line.md b/docs/assets/option/en/component/crosshair-common/crosshair-line.md index 6432667b85..e9bad9bdee 100644 --- a/docs/assets/option/en/component/crosshair-common/crosshair-line.md +++ b/docs/assets/option/en/component/crosshair-common/crosshair-line.md @@ -16,7 +16,8 @@ Only effective for `type: 'line'`, `width` represents the width of the auxiliary #${prefix} smooth(boolean) -Only effective for `type: 'line'`, whether to draw smoothly under the polar coordinate system or not. +Whether to draw smoothly under the polar coordinate system or not. +Effective for `type: 'line'`, and effective for `type: 'polygon'` since version `1.13.5`. {{ else }} #${prefix} width(number|string) diff --git a/docs/assets/option/zh/component/crosshair-common/crosshair-line.md b/docs/assets/option/zh/component/crosshair-common/crosshair-line.md index 8793981356..f35e4b74ae 100644 --- a/docs/assets/option/zh/component/crosshair-common/crosshair-line.md +++ b/docs/assets/option/zh/component/crosshair-common/crosshair-line.md @@ -16,7 +16,7 @@ crosshair 辅助线的类型,可选值为 `'line'` 和 `'rect'`。 #${prefix} smooth(boolean) -仅对 `type: 'line'` 生效,极坐标系下是否平滑绘制。 +极坐标系下是否平滑绘制。对 `type: 'line'` 生效,自版本 `1.13.5` 后支持 `type: 'polygon'`。 {{ else }} #${prefix} width(number|string) diff --git a/packages/vchart/src/component/crosshair/base.ts b/packages/vchart/src/component/crosshair/base.ts index 042140159e..26cd3e6911 100644 --- a/packages/vchart/src/component/crosshair/base.ts +++ b/packages/vchart/src/component/crosshair/base.ts @@ -527,6 +527,7 @@ export abstract class BaseCrossHair let crosshair; if (coordKey === 'angle') { - const crosshairType = attributes.type === 'rect' ? 'sector' : 'line'; + const isSmooth = attributes.smooth === true; + const crosshairType = attributes.type === 'rect' ? (isSmooth ? 'sector' : 'polygon-sector') : 'line'; // 创建 if (crosshairType === 'line') { crosshair = new LineCrosshair({ @@ -212,6 +219,19 @@ export class PolarCrossHair zIndex: this.gridZIndex, pickable: false }); + } else if (crosshairType === 'polygon-sector') { + crosshair = new PolygonSectorCrosshair({ + ...(positionAttrs as { + center: IPoint; + innerRadius: number; + radius: number; + startAngle: number; + endAngle: number; + }), + polygonSectorStyle: attributes.style, + zIndex: this.gridZIndex, + pickable: false + }); } } else { const crosshairType = smooth ? 'circle' : 'polygon';