@@ -95,7 +95,19 @@ module.exports = function plot(gd, cdpie) {
95
95
// in case fullLayout or fullData has changed without a replot
96
96
var fullLayout2 = gd . _fullLayout ;
97
97
var trace2 = gd . _fullData [ trace . index ] ;
98
- var hoverinfo = Fx . castHoverinfo ( trace2 , fullLayout2 , pt . i ) ;
98
+
99
+ var hoverinfo = trace2 . hoverinfo ;
100
+ if ( Array . isArray ( hoverinfo ) ) {
101
+ // super hacky: we need to pull out the *first* hoverinfo from
102
+ // pt.pts, then put it back into an array in a dummy trace
103
+ // and call castHoverinfo on that.
104
+ // TODO: do we want to have Fx.castHoverinfo somehow handle this?
105
+ // it already takes an array for index, for 2D, so this seems tricky.
106
+ hoverinfo = Fx . castHoverinfo ( {
107
+ hoverinfo : [ helpers . castOption ( hoverinfo , pt . pts ) ] ,
108
+ _module : trace . _module
109
+ } , fullLayout2 , 0 ) ;
110
+ }
99
111
100
112
if ( hoverinfo === 'all' ) hoverinfo = 'label+text+value+percent+name' ;
101
113
@@ -115,31 +127,27 @@ module.exports = function plot(gd, cdpie) {
115
127
116
128
if ( hoverinfo . indexOf ( 'label' ) !== - 1 ) thisText . push ( pt . label ) ;
117
129
if ( hoverinfo . indexOf ( 'text' ) !== - 1 ) {
118
- if ( trace2 . hovertext ) {
119
- thisText . push (
120
- Array . isArray ( trace2 . hovertext ) ?
121
- trace2 . hovertext [ pt . i ] :
122
- trace2 . hovertext
123
- ) ;
124
- } else if ( trace2 . text && trace2 . text [ pt . i ] ) {
125
- thisText . push ( trace2 . text [ pt . i ] ) ;
126
- }
130
+ var texti = helpers . castOption ( trace2 . hovertext || trace2 . text , pt . pts ) ;
131
+ if ( texti ) thisText . push ( texti ) ;
127
132
}
128
133
if ( hoverinfo . indexOf ( 'value' ) !== - 1 ) thisText . push ( helpers . formatPieValue ( pt . v , separators ) ) ;
129
134
if ( hoverinfo . indexOf ( 'percent' ) !== - 1 ) thisText . push ( helpers . formatPiePercent ( pt . v / cd0 . vTotal , separators ) ) ;
130
135
136
+ var hoverLabel = trace . hoverlabel ;
137
+ var hoverFont = hoverLabel . font ;
138
+
131
139
Fx . loneHover ( {
132
140
x0 : hoverCenterX - rInscribed * cd0 . r ,
133
141
x1 : hoverCenterX + rInscribed * cd0 . r ,
134
142
y : hoverCenterY ,
135
143
text : thisText . join ( '<br>' ) ,
136
144
name : hoverinfo . indexOf ( 'name' ) !== - 1 ? trace2 . name : undefined ,
137
145
idealAlign : pt . pxmid [ 0 ] < 0 ? 'left' : 'right' ,
138
- color : Fx . castHoverOption ( trace , pt . i , 'bgcolor' ) || pt . color ,
139
- borderColor : Fx . castHoverOption ( trace , pt . i , 'bordercolor' ) ,
140
- fontFamily : Fx . castHoverOption ( trace , pt . i , 'font.family' ) ,
141
- fontSize : Fx . castHoverOption ( trace , pt . i , 'font.size' ) ,
142
- fontColor : Fx . castHoverOption ( trace , pt . i , 'font.color' )
146
+ color : helpers . castOption ( hoverLabel . bgcolor , pt . pts ) || pt . color ,
147
+ borderColor : helpers . castOption ( hoverLabel . bordercolor , pt . pts ) ,
148
+ fontFamily : helpers . castOption ( hoverFont . family , pt . pts ) ,
149
+ fontSize : helpers . castOption ( hoverFont . size , pt . pts ) ,
150
+ fontColor : helpers . castOption ( hoverFont . color , pt . pts )
143
151
} , {
144
152
container : fullLayout2 . _hoverlayer . node ( ) ,
145
153
outerContainer : fullLayout2 . _paper . node ( ) ,
@@ -182,7 +190,7 @@ module.exports = function plot(gd, cdpie) {
182
190
. on ( 'click' , handleClick ) ;
183
191
184
192
if ( trace . pull ) {
185
- var pull = + ( Array . isArray ( trace . pull ) ? trace . pull [ pt . i ] : trace . pull ) || 0 ;
193
+ var pull = + helpers . castOption ( trace . pull , pt . pts ) || 0 ;
186
194
if ( pull > 0 ) {
187
195
cx += pull * pt . pxmid [ 0 ] ;
188
196
cy += pull * pt . pxmid [ 1 ] ;
@@ -233,8 +241,7 @@ module.exports = function plot(gd, cdpie) {
233
241
}
234
242
235
243
// add text
236
- var textPosition = Array . isArray ( trace . textposition ) ?
237
- trace . textposition [ pt . i ] : trace . textposition ,
244
+ var textPosition = helpers . castOption ( trace . textposition , pt . pts ) ,
238
245
sliceTextGroup = sliceTop . selectAll ( 'g.slicetext' )
239
246
. data ( pt . text && ( textPosition !== 'none' ) ? [ 0 ] : [ ] ) ;
240
247
@@ -492,7 +499,12 @@ function scootLabels(quadrants, trace) {
492
499
otherPt = wholeSide [ i ] ;
493
500
494
501
// overlap can only happen if the other point is pulled more than this one
495
- if ( otherPt === thisPt || ( ( trace . pull [ thisPt . i ] || 0 ) >= trace . pull [ otherPt . i ] || 0 ) ) continue ;
502
+ if ( otherPt === thisPt || (
503
+ ( helpers . castOption ( trace . pull , thisPt . pts ) || 0 ) >=
504
+ ( helpers . castOption ( trace . pull , otherPt . pts ) || 0 ) )
505
+ ) {
506
+ continue ;
507
+ }
496
508
497
509
if ( ( thisPt . pxmid [ 1 ] - otherPt . pxmid [ 1 ] ) * yDiffSign > 0 ) {
498
510
// closer to the equator - by construction all of these happen first
0 commit comments