@@ -85,27 +85,36 @@ function calc(gd, trace) {
85
85
// include the sum of all values in the first point
86
86
if ( cd [ 0 ] ) cd [ 0 ] . vTotal = vTotal ;
87
87
88
- // now insert text
89
88
if ( trace . textinfo && trace . textinfo !== 'none' ) {
90
- var hasLabel = trace . textinfo . indexOf ( 'label' ) !== - 1 ;
91
- var hasText = trace . textinfo . indexOf ( 'text' ) !== - 1 ;
92
- var hasValue = trace . textinfo . indexOf ( 'value' ) !== - 1 ;
93
- var hasPercent = trace . textinfo . indexOf ( 'percent' ) !== - 1 ;
94
- var separators = fullLayout . separators ;
95
-
96
- var thisText ;
97
-
98
- for ( i = 0 ; i < cd . length ; i ++ ) {
99
- pt = cd [ i ] ;
100
- thisText = hasLabel ? [ pt . label ] : [ ] ;
101
- if ( hasText ) {
102
- var texti = helpers . getFirstFilled ( trace . text , pt . pts ) ;
103
- if ( texti ) thisText . push ( texti ) ;
104
- }
105
- if ( hasValue ) thisText . push ( helpers . formatPieValue ( pt . v , separators ) ) ;
106
- if ( hasPercent ) thisText . push ( helpers . formatPiePercent ( pt . v / vTotal , separators ) ) ;
107
- pt . text = thisText . join ( '<br>' ) ;
89
+ // now insert text
90
+ cd = insertText ( gd , trace , cd , vTotal ) ;
91
+ }
92
+
93
+ return cd ;
94
+ }
95
+
96
+ function insertText ( gd , trace , cd , vTotal ) {
97
+ var fullLayout = gd . _fullLayout ;
98
+ var i , pt ;
99
+
100
+ var hasLabel = trace . textinfo . indexOf ( 'label' ) !== - 1 ;
101
+ var hasText = trace . textinfo . indexOf ( 'text' ) !== - 1 ;
102
+ var hasValue = trace . textinfo . indexOf ( 'value' ) !== - 1 ;
103
+ var hasPercent = trace . textinfo . indexOf ( 'percent' ) !== - 1 ;
104
+ var separators = fullLayout . separators ;
105
+
106
+ var thisText ;
107
+
108
+ for ( i = 0 ; i < cd . length ; i ++ ) {
109
+ pt = cd [ i ] ;
110
+ thisText = hasLabel ? [ pt . label ] : [ ] ;
111
+ if ( hasText ) {
112
+ var texti = helpers . getFirstFilled ( trace . text , pt . pts ) ;
113
+ if ( texti ) thisText . push ( texti ) ;
108
114
}
115
+ if ( hasValue ) thisText . push ( helpers . formatPieValue ( pt . v , separators ) ) ;
116
+ if ( hasPercent ) thisText . push ( helpers . formatPiePercent ( pt . v / vTotal , separators ) ) ;
117
+ pt . text = thisText . join ( '<br>' ) ;
109
118
}
110
119
111
120
return cd ;
@@ -189,6 +198,7 @@ function generateExtendedColors(colorList, extendedColorWays) {
189
198
module . exports = {
190
199
calc : calc ,
191
200
crossTraceCalc : crossTraceCalc ,
201
+ insertText : insertText ,
192
202
193
203
makePullColorFn : makePullColorFn ,
194
204
generateExtendedColors : generateExtendedColors
0 commit comments