@@ -568,12 +568,12 @@ function setBaseAndTop(sa, sieve) {
568568 }
569569 }
570570
571- const textPadding = estimateExtraPaddingForText ( fullTrace , calcTrace ) ;
571+ const extraPad = estimateAxisPaddingForText ( fullTrace , calcTrace ) ;
572572 fullTrace . _extremes [ sa . _id ] = Axes . findExtremes ( sa , pts , {
573573 tozero : tozero ,
574574 padded : true ,
575- ppadplus : textPadding . ppadplus ,
576- ppadminus : textPadding . ppadminus
575+ ppadplus : extraPad . ppadplus ,
576+ ppadminus : extraPad . ppadminus
577577 } ) ;
578578 }
579579}
@@ -643,17 +643,16 @@ function stackBars(sa, sieve, opts) {
643643 }
644644 }
645645
646- const textPadding = estimateExtraPaddingForText ( fullTrace , calcTrace ) ;
647-
648646 // if barnorm is set, let normalizeBars update the axis range
649647 if ( ! opts . norm ) {
648+ const extraPad = estimateAxisPaddingForText ( fullTrace , calcTrace ) ;
650649 fullTrace . _extremes [ sa . _id ] = Axes . findExtremes ( sa , pts , {
651650 // N.B. we don't stack base with 'base',
652651 // so set tozero:true always!
653652 tozero : true ,
654653 padded : true ,
655- ppadplus : textPadding . ppadplus ,
656- ppadminus : textPadding . ppadminus
654+ ppadplus : extraPad . ppadplus ,
655+ ppadminus : extraPad . ppadminus
657656 } ) ;
658657 }
659658 }
@@ -757,13 +756,12 @@ function normalizeBars(sa, sieve, opts) {
757756 }
758757 }
759758
760- const textPadding = estimateExtraPaddingForText ( fullTrace , calcTrace ) ;
761-
759+ const extraPad = estimateAxisPaddingForText ( fullTrace , calcTrace ) ;
762760 fullTrace . _extremes [ sa . _id ] = Axes . findExtremes ( sa , pts , {
763761 tozero : tozero ,
764762 padded : padded ,
765- ppadplus : textPadding . ppadplus ,
766- ppadminus : textPadding . ppadminus
763+ ppadplus : extraPad . ppadplus ,
764+ ppadminus : extraPad . ppadminus
767765 } ) ;
768766 }
769767}
@@ -777,11 +775,11 @@ function normalizeBars(sa, sieve, opts) {
777775// bar chart with textposition set to 'outside' experiences text
778776// labels being cut off at the edge of the plot area.
779777//
780- // More complex scenarios (horizontal bars, multi-line text labels )
778+ // More complex scenarios (horizontal bars, various text angles )
781779// are not (yet) handled here, but could be in the future.
782780// Returns an object with ppadplus and ppadminus values,
783781// to be passed into Axes.findExtremes.
784- function estimateExtraPaddingForText ( trace , calcTrace ) {
782+ function estimateAxisPaddingForText ( trace , calcTrace ) {
785783 if (
786784 trace . orientation === 'v' &&
787785 ( trace . text || trace . texttemplate ) &&
@@ -805,7 +803,7 @@ function estimateExtraPaddingForText(trace, calcTrace) {
805803 ppadminus : calcTrace . some ( ( bar ) => bar . s >= 0 ) ? padAmount : 0
806804 } ;
807805 }
808- return 0 ;
806+ return { ppadplus : undefined , ppadminus : undefined } ;
809807}
810808
811809// Add an `_sMin` and `_sMax` value for each bar representing the min and max size value
0 commit comments