Files
HRM-System/node_modules/recharts/es6/util/cursor/getCursorPoints.js
2026-04-13 09:30:59 +08:00

45 lines
1.1 KiB
JavaScript

import { polarToCartesian } from '../PolarUtils';
import { isPolarCoordinate } from '../types';
import { getRadialCursorPoints } from './getRadialCursorPoints';
export function getCursorPoints(layout, activeCoordinate, offset) {
if (layout === 'horizontal') {
return [{
x: activeCoordinate.x,
y: offset.top
}, {
x: activeCoordinate.x,
y: offset.top + offset.height
}];
}
if (layout === 'vertical') {
return [{
x: offset.left,
y: activeCoordinate.y
}, {
x: offset.left + offset.width,
y: activeCoordinate.y
}];
}
if (isPolarCoordinate(activeCoordinate)) {
if (layout === 'centric') {
var {
cx,
cy,
innerRadius,
outerRadius,
angle
} = activeCoordinate;
var innerPoint = polarToCartesian(cx, cy, innerRadius, angle);
var outerPoint = polarToCartesian(cx, cy, outerRadius, angle);
return [{
x: innerPoint.x,
y: innerPoint.y
}, {
x: outerPoint.x,
y: outerPoint.y
}];
}
return getRadialCursorPoints(activeCoordinate);
}
return undefined;
}