From bdae17e817e393dd73b1441593a4879ca80d926f Mon Sep 17 00:00:00 2001 From: xiaoluoHe Date: Wed, 25 Dec 2024 10:41:02 +0800 Subject: [PATCH 1/3] 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'; From f80d29ad3997a4d2fffc6fb68c080c4149cec7e8 Mon Sep 17 00:00:00 2001 From: xiaoluoHe Date: Wed, 25 Dec 2024 10:50:18 +0800 Subject: [PATCH 2/3] docs: add changelog --- .../feat-polar-polyon-crosshair_2024-12-25-02-49.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@visactor/vchart/feat-polar-polyon-crosshair_2024-12-25-02-49.json diff --git a/common/changes/@visactor/vchart/feat-polar-polyon-crosshair_2024-12-25-02-49.json b/common/changes/@visactor/vchart/feat-polar-polyon-crosshair_2024-12-25-02-49.json new file mode 100644 index 0000000000..9523a60166 --- /dev/null +++ b/common/changes/@visactor/vchart/feat-polar-polyon-crosshair_2024-12-25-02-49.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@visactor/vchart", + "comment": " feat: support polygon crosshair for angleAxis in polar coordinate, #3458", + "type": "none" + } + ], + "packageName": "@visactor/vchart" +} \ No newline at end of file From 4fcf2c3940e3eaa348c02449cfe6b7a04a68e143 Mon Sep 17 00:00:00 2001 From: xiaoluoHe Date: Sun, 26 Jan 2025 15:50:20 +0800 Subject: [PATCH 3/3] fix: type defination --- packages/vchart/src/component/crosshair/interface/spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vchart/src/component/crosshair/interface/spec.ts b/packages/vchart/src/component/crosshair/interface/spec.ts index 268b7ae03a..ac5d019094 100644 --- a/packages/vchart/src/component/crosshair/interface/spec.ts +++ b/packages/vchart/src/component/crosshair/interface/spec.ts @@ -130,7 +130,6 @@ export interface ICrosshairLineSpec { width?: number; /** * 极坐标系下是否平滑 - * @since 1.13.5 */ smooth?: boolean; /** @@ -158,6 +157,7 @@ export interface ICrosshairRectSpec { width?: number | string | ICrosshairRectWidthCallback; /** * 极坐标系下是否平滑 + * @since 1.13.5 */ smooth?: boolean; /**