Skip to content

Commit

Permalink
refactor: reuse util function
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoluoHe committed Dec 24, 2024
1 parent d7b845d commit c671a2a
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/vrender-components/src/crosshair/polygon-sector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CrosshairBase } from './base';
import type { PolygonSectorCrosshairAttrs } from './type';
import type { ComponentOptions } from '../interface';
import { loadPolygonSectorCrosshairComponent } from './register';
import { getPolygonPath } from '../axis';

loadPolygonSectorCrosshairComponent();
export class PolygonSectorCrosshair extends CrosshairBase<PolygonSectorCrosshairAttrs> {
Expand All @@ -32,17 +33,11 @@ export class PolygonSectorCrosshair extends CrosshairBase<PolygonSectorCrosshair
points.push(polarToCartesian(center, radius, (startAngle + endAngle) / 2));
points.push(polarToCartesian(center, radius * Math.cos((endAngle - startAngle) / 2), endAngle));
points.push(polarToCartesian(center, innerRadius, endAngle));
const path = points.reduce((acc, cur, index) => {
if (index === 0) {
return `M${cur.x},${cur.y}`;
}
return acc + `L${cur.x},${cur.y}`;
}, '');

const polygon = container.createOrUpdateChild(
'crosshair-polygon-sector',
{
path,
path: getPolygonPath(points, true),
...polygonSectorStyle
},
'path'
Expand Down

0 comments on commit c671a2a

Please sign in to comment.