Skip to content

feat: support polygon crosshair for angleAxis in polar coordinate #3604

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

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/vchart",
"comment": " feat: support polygon crosshair for angleAxis in polar coordinate, #3458",
"type": "none"
}
],
"packageName": "@visactor/vchart"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ crosshair 辅助线的类型,可选值为 `'line'` 和 `'rect'`。

#${prefix} smooth(boolean)

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

{{ else }}
#${prefix} width(number|string)
Expand Down
2 changes: 1 addition & 1 deletion packages/vchart/src/component/crosshair/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr

hair.visible = visible;
hair.type = line.type || 'line';
hair.smooth = line.smooth;

if (line.visible === false) {
hair.style = { visible: false };
Expand Down Expand Up @@ -611,7 +612,6 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
} else {
hair.label = { visible: false };
}

return hair;
}

Expand Down
5 changes: 5 additions & 0 deletions packages/vchart/src/component/crosshair/interface/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ export interface ICrosshairRectSpec {
* @default '100%''
*/
width?: number | string | ICrosshairRectWidthCallback;
/**
* 极坐标系下是否平滑
* @since 1.13.5
*/
smooth?: boolean;
/**
* 辅助图形的样式配置
*/
Expand Down
24 changes: 22 additions & 2 deletions packages/vchart/src/component/crosshair/polar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import type { IComponentOption } from '../interface';
import { ComponentTypeEnum } from '../interface/type';
import type { IPolarCrosshairSpec } from './interface';
import type { PolygonCrosshairAttrs, CircleCrosshairAttrs } from '@visactor/vrender-components';
import { LineCrosshair, SectorCrosshair, CircleCrosshair, PolygonCrosshair } from '@visactor/vrender-components';
import {
LineCrosshair,
SectorCrosshair,
CircleCrosshair,
PolygonCrosshair,
PolygonSectorCrosshair
} from '@visactor/vrender-components';
import type { IPolarAxis } from '../axis/polar/interface';
import type { IPoint, IPolarOrientType, StringOrNumber, TooltipActiveType, TooltipData } from '../../typings';
import { BaseCrossHair } from './base';
Expand Down Expand Up @@ -190,7 +196,8 @@ export class PolarCrossHair<T extends IPolarCrosshairSpec = IPolarCrosshairSpec>
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({
Expand All @@ -212,6 +219,19 @@ export class PolarCrossHair<T extends IPolarCrosshairSpec = IPolarCrosshairSpec>
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';
Expand Down
Loading