[Dashboards] Dynamic paddings (#17298)
closes https://github.com/twentyhq/core-team-issues/issues/2055 https://github.com/user-attachments/assets/7a19066f-e891-4dfa-92ee-b85690765e60
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
import { COMMON_CHART_CONSTANTS } from '@/page-layout/widgets/graph/constants/CommonChartConstants';
|
||||
import { estimateLineHeight } from '@/page-layout/widgets/graph/utils/estimateLineHeight';
|
||||
|
||||
export const estimateRotatedHeight = (
|
||||
maxLength: number,
|
||||
fontSize: number,
|
||||
rotationDegrees: number,
|
||||
) => {
|
||||
if (rotationDegrees === 0 || maxLength <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const labelWidth =
|
||||
maxLength *
|
||||
fontSize *
|
||||
COMMON_CHART_CONSTANTS.ROTATED_TICK_LABEL_WIDTH_ESTIMATE_RATIO;
|
||||
if (labelWidth <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const labelHeight = estimateLineHeight(fontSize);
|
||||
const rotationRadians = (Math.abs(rotationDegrees) * Math.PI) / 180;
|
||||
const projectedHeight =
|
||||
Math.abs(labelWidth * Math.sin(rotationRadians)) +
|
||||
Math.abs(labelHeight * Math.cos(rotationRadians));
|
||||
|
||||
return Math.max(labelHeight, projectedHeight);
|
||||
};
|
||||
Reference in New Issue
Block a user