Skip to content

Commit bdae17e

Browse files
committed
feat: support polygon crosshair for angleAxis in polar coordinate
1 parent 4d720b4 commit bdae17e

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

docs/assets/option/en/component/crosshair-common/crosshair-line.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Only effective for `type: 'line'`, `width` represents the width of the auxiliary
1616

1717
#${prefix} smooth(boolean)
1818

19-
Only effective for `type: 'line'`, whether to draw smoothly under the polar coordinate system or not.
19+
Whether to draw smoothly under the polar coordinate system or not.
20+
Effective for `type: 'line'`, and effective for `type: 'polygon'` since version `1.13.5`.
2021

2122
{{ else }}
2223
#${prefix} width(number|string)

docs/assets/option/zh/component/crosshair-common/crosshair-line.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ crosshair 辅助线的类型,可选值为 `'line'` 和 `'rect'`。
1616

1717
#${prefix} smooth(boolean)
1818

19-
仅对 `type: 'line'` 生效,极坐标系下是否平滑绘制
19+
极坐标系下是否平滑绘制。对 `type: 'line'` 生效,自版本 `1.13.5` 后支持 `type: 'polygon'`
2020

2121
{{ else }}
2222
#${prefix} width(number|string)

packages/vchart/src/component/crosshair/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
527527

528528
hair.visible = visible;
529529
hair.type = line.type || 'line';
530+
hair.smooth = line.smooth;
530531

531532
if (line.visible === false) {
532533
hair.style = { visible: false };
@@ -611,7 +612,6 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
611612
} else {
612613
hair.label = { visible: false };
613614
}
614-
615615
return hair;
616616
}
617617

packages/vchart/src/component/crosshair/interface/spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export interface ICrosshairLineSpec {
130130
width?: number;
131131
/**
132132
* 极坐标系下是否平滑
133+
* @since 1.13.5
133134
*/
134135
smooth?: boolean;
135136
/**
@@ -155,6 +156,10 @@ export interface ICrosshairRectSpec {
155156
* @default '100%''
156157
*/
157158
width?: number | string | ICrosshairRectWidthCallback;
159+
/**
160+
* 极坐标系下是否平滑
161+
*/
162+
smooth?: boolean;
158163
/**
159164
* 辅助图形的样式配置
160165
*/

packages/vchart/src/component/crosshair/polar.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import type { IComponentOption } from '../interface';
44
import { ComponentTypeEnum } from '../interface/type';
55
import type { IPolarCrosshairSpec } from './interface';
66
import type { PolygonCrosshairAttrs, CircleCrosshairAttrs } from '@visactor/vrender-components';
7-
import { LineCrosshair, SectorCrosshair, CircleCrosshair, PolygonCrosshair } from '@visactor/vrender-components';
7+
import {
8+
LineCrosshair,
9+
SectorCrosshair,
10+
CircleCrosshair,
11+
PolygonCrosshair,
12+
PolygonSectorCrosshair
13+
} from '@visactor/vrender-components';
814
import type { IPolarAxis } from '../axis/polar/interface';
915
import type { IPoint, IPolarOrientType, StringOrNumber, TooltipActiveType, TooltipData } from '../../typings';
1016
import { BaseCrossHair } from './base';
@@ -190,7 +196,8 @@ export class PolarCrossHair<T extends IPolarCrosshairSpec = IPolarCrosshairSpec>
190196
let crosshair;
191197

192198
if (coordKey === 'angle') {
193-
const crosshairType = attributes.type === 'rect' ? 'sector' : 'line';
199+
const isSmooth = attributes.smooth === true;
200+
const crosshairType = attributes.type === 'rect' ? (isSmooth ? 'sector' : 'polygon-sector') : 'line';
194201
// 创建
195202
if (crosshairType === 'line') {
196203
crosshair = new LineCrosshair({
@@ -212,6 +219,19 @@ export class PolarCrossHair<T extends IPolarCrosshairSpec = IPolarCrosshairSpec>
212219
zIndex: this.gridZIndex,
213220
pickable: false
214221
});
222+
} else if (crosshairType === 'polygon-sector') {
223+
crosshair = new PolygonSectorCrosshair({
224+
...(positionAttrs as {
225+
center: IPoint;
226+
innerRadius: number;
227+
radius: number;
228+
startAngle: number;
229+
endAngle: number;
230+
}),
231+
polygonSectorStyle: attributes.style,
232+
zIndex: this.gridZIndex,
233+
pickable: false
234+
});
215235
}
216236
} else {
217237
const crosshairType = smooth ? 'circle' : 'polygon';

0 commit comments

Comments
 (0)