File tree Expand file tree Collapse file tree 2 files changed +12
-26
lines changed Expand file tree Collapse file tree 2 files changed +12
-26
lines changed Original file line number Diff line number Diff line change @@ -16,19 +16,12 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
1616} ;
1717
1818function dfltLabelYanchor ( isLine , labelTextPosition ) {
19- var dfltYanchor ;
20- if ( isLine ) {
21- dfltYanchor = 'bottom' ;
22- } else {
23- if ( labelTextPosition . indexOf ( 'top' ) !== - 1 ) {
24- dfltYanchor = 'top' ;
25- } else if ( labelTextPosition . indexOf ( 'bottom' ) !== - 1 ) {
26- dfltYanchor = 'bottom' ;
27- } else {
28- dfltYanchor = 'middle' ;
29- }
30- }
31- return dfltYanchor ;
19+ // If shape is a line, default y-anchor is 'bottom' (so that text is above line by default)
20+ // Otherwise, default y-anchor is equal to y-component of `textposition`
21+ // (so that text is positioned inside shape bounding box by default)
22+ return isLine ? 'bottom' :
23+ labelTextPosition . indexOf ( 'top' ) !== - 1 ? 'top' :
24+ labelTextPosition . indexOf ( 'bottom' ) !== - 1 ? 'bottom' : 'middle' ;
3225}
3326
3427function handleShapeDefaults ( shapeIn , shapeOut , fullLayout ) {
Original file line number Diff line number Diff line change @@ -5,19 +5,12 @@ var Lib = require('../../../lib');
55
66
77function dfltLabelYanchor ( isLine , labelTextPosition ) {
8- var dfltYanchor ;
9- if ( isLine ) {
10- dfltYanchor = 'bottom' ;
11- } else {
12- if ( labelTextPosition . indexOf ( 'top' ) !== - 1 ) {
13- dfltYanchor = 'top' ;
14- } else if ( labelTextPosition . indexOf ( 'bottom' ) !== - 1 ) {
15- dfltYanchor = 'bottom' ;
16- } else {
17- dfltYanchor = 'middle' ;
18- }
19- }
20- return dfltYanchor ;
8+ // If shape is a line, default y-anchor is 'bottom' (so that text is above line by default)
9+ // Otherwise, default y-anchor is equal to y-component of `textposition`
10+ // (so that text is positioned inside shape bounding box by default)
11+ return isLine ? 'bottom' :
12+ labelTextPosition . indexOf ( 'top' ) !== - 1 ? 'top' :
13+ labelTextPosition . indexOf ( 'bottom' ) !== - 1 ? 'bottom' : 'middle' ;
2114}
2215
2316module . exports = function supplyDrawNewShapeDefaults ( layoutIn , layoutOut , coerce ) {
You can’t perform that action at this time.
0 commit comments