@@ -95,7 +95,19 @@ module.exports = function plot(gd, cdpie) {
9595 // in case fullLayout or fullData has changed without a replot
9696 var fullLayout2 = gd . _fullLayout ;
9797 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+ }
99111
100112 if ( hoverinfo === 'all' ) hoverinfo = 'label+text+value+percent+name' ;
101113
@@ -115,31 +127,27 @@ module.exports = function plot(gd, cdpie) {
115127
116128 if ( hoverinfo . indexOf ( 'label' ) !== - 1 ) thisText . push ( pt . label ) ;
117129 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 ) ;
127132 }
128133 if ( hoverinfo . indexOf ( 'value' ) !== - 1 ) thisText . push ( helpers . formatPieValue ( pt . v , separators ) ) ;
129134 if ( hoverinfo . indexOf ( 'percent' ) !== - 1 ) thisText . push ( helpers . formatPiePercent ( pt . v / cd0 . vTotal , separators ) ) ;
130135
136+ var hoverLabel = trace . hoverlabel ;
137+ var hoverFont = hoverLabel . font ;
138+
131139 Fx . loneHover ( {
132140 x0 : hoverCenterX - rInscribed * cd0 . r ,
133141 x1 : hoverCenterX + rInscribed * cd0 . r ,
134142 y : hoverCenterY ,
135143 text : thisText . join ( '<br>' ) ,
136144 name : hoverinfo . indexOf ( 'name' ) !== - 1 ? trace2 . name : undefined ,
137145 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 )
143151 } , {
144152 container : fullLayout2 . _hoverlayer . node ( ) ,
145153 outerContainer : fullLayout2 . _paper . node ( ) ,
@@ -182,7 +190,7 @@ module.exports = function plot(gd, cdpie) {
182190 . on ( 'click' , handleClick ) ;
183191
184192 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 ;
186194 if ( pull > 0 ) {
187195 cx += pull * pt . pxmid [ 0 ] ;
188196 cy += pull * pt . pxmid [ 1 ] ;
@@ -233,8 +241,7 @@ module.exports = function plot(gd, cdpie) {
233241 }
234242
235243 // 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 ) ,
238245 sliceTextGroup = sliceTop . selectAll ( 'g.slicetext' )
239246 . data ( pt . text && ( textPosition !== 'none' ) ? [ 0 ] : [ ] ) ;
240247
@@ -492,7 +499,12 @@ function scootLabels(quadrants, trace) {
492499 otherPt = wholeSide [ i ] ;
493500
494501 // 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+ }
496508
497509 if ( ( thisPt . pxmid [ 1 ] - otherPt . pxmid [ 1 ] ) * yDiffSign > 0 ) {
498510 // closer to the equator - by construction all of these happen first
0 commit comments