@@ -1041,8 +1041,8 @@ function updateStyle(
10411041 )
10421042 )
10431043 : ( isHorizontalOrRadial
1044- ? ( ( layout as RectLayout ) . height >= 0 ? 'bottom' : 'top' )
1045- : ( ( layout as RectLayout ) . width >= 0 ? 'right' : 'left' ) ) ;
1044+ ? getLabelPositionForHorizontal ( layout as RectLayout , seriesModel . coordinateSystem )
1045+ : getLabelPositionForVertical ( layout as RectLayout , seriesModel . coordinateSystem ) ) ;
10461046
10471047 const labelStatesModels = getLabelStatesModels ( itemModel ) ;
10481048
@@ -1288,4 +1288,22 @@ function createBackgroundEl(
12881288 } ) ;
12891289}
12901290
1291+ function getLabelPositionForHorizontal ( layout : RectLayout , coordSys : CoordSysOfBar ) : 'top' | 'bottom' {
1292+ if ( layout . height === 0 ) {
1293+ // For zero height, determine position based on axis inverse status
1294+ const valueAxis = ( coordSys as Cartesian2D ) . getOtherAxis ( ( coordSys as Cartesian2D ) . getBaseAxis ( ) ) ;
1295+ return valueAxis . inverse ? 'bottom' : 'top' ;
1296+ }
1297+ return layout . height > 0 ? 'bottom' : 'top' ;
1298+ }
1299+
1300+ function getLabelPositionForVertical ( layout : RectLayout , coordSys : CoordSysOfBar ) : 'left' | 'right' {
1301+ if ( layout . width === 0 ) {
1302+ // For zero width, determine position based on axis inverse status
1303+ const valueAxis = ( coordSys as Cartesian2D ) . getOtherAxis ( ( coordSys as Cartesian2D ) . getBaseAxis ( ) ) ;
1304+ return valueAxis . inverse ? 'left' : 'right' ;
1305+ }
1306+ return layout . width >= 0 ? 'right' : 'left' ;
1307+ }
1308+
12911309export default BarView ;
0 commit comments