11'use strict' ;
22
3- var isNumeric = require ( 'fast-isnumeric' ) ;
4- var isArrayOrTypedArray = require ( '../../lib' ) . isArrayOrTypedArray ;
5- var BADNUM = require ( '../../constants/numerical' ) . BADNUM ;
3+ const isNumeric = require ( 'fast-isnumeric' ) ;
4+ const { isArrayOrTypedArray} = require ( '../../lib' ) ;
5+ const { BADNUM } = require ( '../../constants/numerical' ) ;
66
7- var Registry = require ( '../../registry' ) ;
8- var Axes = require ( '../../plots/cartesian/axes' ) ;
9- var getAxisGroup = require ( '../../plots/cartesian/constraints' ) . getAxisGroup ;
10- var Sieve = require ( './sieve.js' ) ;
7+ const Registry = require ( '../../registry' ) ;
8+ const Axes = require ( '../../plots/cartesian/axes' ) ;
9+ const { getAxisGroup} = require ( '../../plots/cartesian/constraints' ) ;
10+ const Sieve = require ( './sieve.js' ) ;
1111
12- var TEXTPAD = require ( './constants' ) . TEXTPAD ;
13- var LINE_SPACING = require ( '../../constants/alignment' ) . LINE_SPACING ;
14- var BR_TAG_ALL = require ( '../../lib/svg_text_utils' ) . BR_TAG_ALL ;
12+ const { TEXTPAD , LINE_SPACING } = require ( './constants' ) ;
13+ const { BR_TAG_ALL } = require ( '../../lib/svg_text_utils' ) ;
1514
1615/*
1716 * Bar chart stacking/grouping positioning and autoscaling calculations
@@ -569,12 +568,12 @@ function setBaseAndTop(sa, sieve) {
569568}
570569}
571570
572- const extraPad = estimateAxisPaddingForText ( fullTrace , calcTrace ) ;
571+ const { ppadminus , ppadplus } = estimateAxisPaddingForText ( fullTrace , calcTrace ) ;
573572fullTrace . _extremes [ sa . _id ] = Axes . findExtremes ( sa , pts , {
574- tozero : tozero ,
573+ tozero,
575574padded :true ,
576- ppadplus : extraPad . ppadplus ,
577- ppadminus : extraPad . ppadminus
575+ ppadplus,
576+ ppadminus
578577} ) ;
579578}
580579}
@@ -646,14 +645,14 @@ function stackBars(sa, sieve, opts) {
646645
647646// if barnorm is set, let normalizeBars update the axis range
648647if ( ! opts . norm ) {
649- const extraPad = estimateAxisPaddingForText ( fullTrace , calcTrace ) ;
648+ const { ppadminus , ppadplus } = estimateAxisPaddingForText ( fullTrace , calcTrace ) ;
650649fullTrace . _extremes [ sa . _id ] = Axes . findExtremes ( sa , pts , {
651650// N.B. we don't stack base with 'base',
652651// so set tozero:true always!
653652tozero :true ,
654653padded :true ,
655- ppadplus : extraPad . ppadplus ,
656- ppadminus : extraPad . ppadminus
654+ ppadplus,
655+ ppadminus
657656} ) ;
658657}
659658}
@@ -757,12 +756,12 @@ function normalizeBars(sa, sieve, opts) {
757756}
758757}
759758
760- const extraPad = estimateAxisPaddingForText ( fullTrace , calcTrace ) ;
759+ const { ppadminus , ppadplus } = estimateAxisPaddingForText ( fullTrace , calcTrace ) ;
761760fullTrace . _extremes [ sa . _id ] = Axes . findExtremes ( sa , pts , {
762- tozero : tozero ,
763- padded : padded ,
764- ppadplus : extraPad . ppadplus ,
765- ppadminus : extraPad . ppadminus
761+ tozero,
762+ padded,
763+ ppadplus,
764+ ppadminus
766765} ) ;
767766}
768767}
@@ -784,15 +783,15 @@ function estimateAxisPaddingForText(trace, calcTrace) {
784783if (
785784trace . orientation === 'v' &&
786785( trace . text || trace . texttemplate ) &&
787- trace . textposition == 'outside' &&
788- ( trace . textangle == 'auto' || trace . textangle == 0 )
786+ trace . textposition === 'outside' &&
787+ ( trace . textangle === 'auto' || trace . textangle = ==0 )
789788) {
790789// count number of lines by counting <br> elements
791790function countLines ( text ) {
792791if ( ! text || typeof text !== 'string' ) return 0 ;
793792return ( text . match ( BR_TAG_ALL ) || [ ] ) . length + 1 ;
794793}
795- var nLines = trace . texttemplate
794+ const nLines = trace . texttemplate
796795 ?countLines ( trace . texttemplate )
797796 :isArrayOrTypedArray ( trace . text )
798797 ?Math . max ( ...trace . text . map ( ( t ) => countLines ( t ) ) )