@@ -13,7 +13,7 @@ import fontSource from '@components/Charts/font';
1313import type { HitTestArgs } from '@components/Charts/hooks' ;
1414import { useChartInteractions , useChartLabelFormats , useChartLabelLayout , useDynamicYDomain , useTooltipData } from '@components/Charts/hooks' ;
1515import type { CartesianChartProps , ChartDataPoint } from '@components/Charts/types' ;
16- import { calculateMinDomainPadding , DEFAULT_CHART_COLOR , measureTextWidth , rotatedLabelCenterCorrection } from '@components/Charts/utils' ;
16+ import { calculateMinDomainPadding , DEFAULT_CHART_COLOR , measureTextWidth , rotatedLabelCenterCorrection , rotatedLabelYOffset } from '@components/Charts/utils' ;
1717import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
1818import useTheme from '@hooks/useTheme' ;
1919import useThemeStyles from '@hooks/useThemeStyles' ;
@@ -163,19 +163,7 @@ function LineChartContent({data, title, titleIcon, isLoading, yAxisUnit, yAxisUn
163163 const fontMetrics = font . getMetrics ( ) ;
164164 const ascent = Math . abs ( fontMetrics . ascent ) ;
165165 const descent = Math . abs ( fontMetrics . descent ) ;
166-
167- // Calculate labelY to maintain consistent LABEL_GAP from axis to closest point of text
168- // At 0°: closest point is top of text (baseline - ascent)
169- // At 45°: closest point is top-right corner, ascent projects as ascent * cos(45°)
170- // At 90°: text is vertical, closest point is at descent from baseline
171- let labelY : number ;
172- if ( angleRad === 0 ) {
173- labelY = args . chartBounds . bottom + LABEL_GAP + ascent ;
174- } else if ( angleRad >= Math . PI / 2 ) {
175- labelY = args . chartBounds . bottom + LABEL_GAP + descent ;
176- } else {
177- labelY = args . chartBounds . bottom + LABEL_GAP + ascent * Math . cos ( angleRad ) ;
178- }
166+ const labelY = args . chartBounds . bottom + LABEL_GAP + rotatedLabelYOffset ( ascent , descent , angleRad ) ;
179167
180168 return truncatedLabels . map ( ( label , i ) => {
181169 if ( i % labelSkipInterval !== 0 ) {
0 commit comments