@@ -33,9 +33,6 @@ export const AxisWidthBand = () => {
3333 | StackedColumnsState
3434 | GroupedColumnsState
3535 | ComboLineColumnState ;
36- const enableTransition = useTransitionStore ( ( state ) => state . enable ) ;
37- const transitionDuration = useTransitionStore ( ( state ) => state . duration ) ;
38- const xAxisTitleOffset = useXAxisTitleOffset ( xScale , getXLabel , xTimeUnit ) ;
3936 const {
4037 labelColor,
4138 gridColor,
@@ -44,13 +41,21 @@ export const AxisWidthBand = () => {
4441 axisLabelFontSize,
4542 domainColor,
4643 } = useChartTheme ( ) ;
44+ const enableTransition = useTransitionStore ( ( state ) => state . enable ) ;
45+ const transitionDuration = useTransitionStore ( ( state ) => state . duration ) ;
46+ const resolvedFontSize =
47+ xScale . bandwidth ( ) > labelFontSize ? labelFontSize : xScale . bandwidth ( ) ;
48+ const xAxisTitleOffset = useXAxisTitleOffset (
49+ xScale ,
50+ getXLabel ,
51+ xTimeUnit ,
52+ resolvedFontSize
53+ ) ;
4754
4855 useEffect ( ( ) => {
4956 if ( ref . current ) {
5057 const rotation = true ;
5158 const hasNegativeValues = yScale . domain ( ) [ 0 ] < 0 ;
52- const fontSize =
53- xScale . bandwidth ( ) > labelFontSize ? labelFontSize : xScale . bandwidth ( ) ;
5459 const axis = axisBottom ( xScale )
5560 . tickSizeOuter ( 0 )
5661 . tickSizeInner ( hasNegativeValues ? - chartHeight : 6 )
@@ -76,14 +81,19 @@ export const AxisWidthBand = () => {
7681 ) ;
7782 g . selectAll ( ".tick text" )
7883 . attr ( "transform" , rotation ? "rotate(90)" : "rotate(0)" )
79- . attr ( "x" , rotation ? fontSize + ( labelFontSize - fontSize ) * 0.6 : 0 )
84+ . attr (
85+ "x" ,
86+ rotation
87+ ? resolvedFontSize + ( labelFontSize - resolvedFontSize ) * 0.6
88+ : 0
89+ )
8090 . attr (
8191 "dy" ,
8292 hasNegativeValues
83- ? fontSize + ( labelFontSize - fontSize )
84- : 0.6 * fontSize + ( labelFontSize - fontSize ) * 0.4
93+ ? resolvedFontSize + ( labelFontSize - resolvedFontSize )
94+ : 0.6 * resolvedFontSize + ( labelFontSize - resolvedFontSize ) * 0.4
8595 )
86- . attr ( "font-size" , fontSize )
96+ . attr ( "font-size" , resolvedFontSize )
8797 . attr ( "font-family" , fontFamily )
8898 . attr ( "fill" , labelColor )
8999 . attr ( "text-anchor" , rotation ? "start" : "unset" ) ;
@@ -105,6 +115,7 @@ export const AxisWidthBand = () => {
105115 yScale ,
106116 formatXDate ,
107117 formatXAxisTick ,
118+ resolvedFontSize ,
108119 ] ) ;
109120
110121 return (
0 commit comments