mirror of
https://github.com/hanzonet/explore.git
synced 2026-10-30 18:16:57 +00:00
13 lines
482 B
TypeScript
13 lines
482 B
TypeScript
import type { ChartMargin, ChartOffset } from 'ui/shared/chart/types';
|
|
|
|
export default function calculateInnerSize(rect: DOMRect | null, margin?: ChartMargin, offsets?: ChartOffset) {
|
|
if (!rect) {
|
|
return { innerWidth: 0, innerHeight: 0 };
|
|
}
|
|
|
|
return {
|
|
innerWidth: Math.max(rect.width - (offsets?.x || 0) - (margin?.left || 0) - (margin?.right || 0), 0),
|
|
innerHeight: Math.max(rect.height - (offsets?.y || 0) - (margin?.bottom || 0) - (margin?.top || 0), 0),
|
|
};
|
|
}
|