@@ -1041,8 +1041,8 @@ function updateStyle(
1041
1041
)
1042
1042
)
1043
1043
: ( 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 ) ) ;
1046
1046
1047
1047
const labelStatesModels = getLabelStatesModels ( itemModel ) ;
1048
1048
@@ -1288,4 +1288,22 @@ function createBackgroundEl(
1288
1288
} ) ;
1289
1289
}
1290
1290
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
+
1291
1309
export default BarView ;
0 commit comments