@@ -490,18 +490,20 @@ export default class BarController extends DatasetController {
490
490
return this . _getAxis ( ) . length ;
491
491
}
492
492
493
- getFirstScaleIdForXAxis ( ) {
493
+ getFirstScaleIdForIndexAxis ( ) {
494
494
const scales = this . chart . scales ;
495
- return Object . keys ( scales ) . filter ( key => scales [ key ] . axis === 'x' ) . shift ( ) ;
495
+ const indexScaleId = this . chart . options . indexAxis ;
496
+ return Object . keys ( scales ) . filter ( key => scales [ key ] . axis === indexScaleId ) . shift ( ) ;
496
497
}
497
498
498
499
_getAxis ( ) {
499
500
const axis = { } ;
500
- const firstScaleAxisId = this . getFirstScaleIdForXAxis ( ) ;
501
+ const firstScaleAxisId = this . getFirstScaleIdForIndexAxis ( ) ;
501
502
for ( const dataset of this . chart . data . datasets ) {
502
- axis [ valueOrDefault ( dataset . xAxisID , firstScaleAxisId ) ] = true ;
503
+ axis [ valueOrDefault (
504
+ this . chart . options . indexAxis === 'x' ? dataset . xAxisID : dataset . yAxisID , firstScaleAxisId
505
+ ) ] = true ;
503
506
}
504
-
505
507
return Object . keys ( axis ) ;
506
508
}
507
509
@@ -644,7 +646,9 @@ export default class BarController extends DatasetController {
644
646
? computeFlexCategoryTraits ( index , ruler , options , stackCount * axisCount )
645
647
: computeFitCategoryTraits ( index , ruler , options , stackCount * axisCount ) ;
646
648
647
- const axisNumber = this . _getAxis ( ) . indexOf ( valueOrDefault ( this . getDataset ( ) . xAxisID , this . getFirstScaleIdForXAxis ( ) ) ) ;
649
+ const axisNumber = this . _getAxis ( ) . indexOf ( valueOrDefault (
650
+ this . chart . options . indexAxis === 'x' ? this . getDataset ( ) . xAxisID : this . getDataset ( ) . yAxisID , this . getFirstScaleIdForIndexAxis ( )
651
+ ) ) ;
648
652
const stackIndex = this . _getStackIndex ( this . index , this . _cachedMeta . stack , skipNull ? index : undefined ) + axisNumber ;
649
653
center = range . start + ( range . chunk * stackIndex ) + ( range . chunk / 2 ) ;
650
654
size = Math . min ( maxBarThickness , range . chunk * range . ratio ) ;
0 commit comments