@@ -37,28 +37,10 @@ module.exports = function plot(gd, cdpie) {
37
37
var pieGroup = d3 . select ( this ) ;
38
38
var cd0 = cd [ 0 ] ;
39
39
var trace = cd0 . trace ;
40
- var tiltRads = 0 ; // trace.tilt * Math.PI / 180,
41
- var depthLength = ( trace . depth || 0 ) * cd0 . r * Math . sin ( tiltRads ) / 2 ;
42
- var tiltAxis = trace . tiltaxis || 0 ;
43
- var tiltAxisRads = tiltAxis * Math . PI / 180 ;
44
- var depthVector = [
45
- depthLength * Math . sin ( tiltAxisRads ) ,
46
- depthLength * Math . cos ( tiltAxisRads )
47
- ] ;
48
- var rSmall = cd0 . r * Math . cos ( tiltRads ) ;
49
-
50
- var pieParts = pieGroup . selectAll ( 'g.part' )
51
- . data ( trace . tilt ? [ 'top' , 'sides' ] : [ 'top' ] ) ;
52
-
53
- pieParts . enter ( ) . append ( 'g' ) . attr ( 'class' , function ( d ) {
54
- return d + ' part' ;
55
- } ) ;
56
- pieParts . exit ( ) . remove ( ) ;
57
- pieParts . order ( ) ;
58
40
59
41
setCoords ( cd ) ;
60
42
61
- pieGroup . selectAll ( '.top' ) . each ( function ( ) {
43
+ pieGroup . each ( function ( ) {
62
44
var slices = d3 . select ( this ) . selectAll ( 'g.slice' ) . data ( cd ) ;
63
45
64
46
slices . enter ( ) . append ( 'g' )
@@ -83,8 +65,8 @@ module.exports = function plot(gd, cdpie) {
83
65
84
66
quadrants [ pt . pxmid [ 1 ] < 0 ? 0 : 1 ] [ pt . pxmid [ 0 ] < 0 ? 0 : 1 ] . push ( pt ) ;
85
67
86
- var cx = cd0 . cx + depthVector [ 0 ] ;
87
- var cy = cd0 . cy + depthVector [ 1 ] ;
68
+ var cx = cd0 . cx ;
69
+ var cy = cd0 . cy ;
88
70
var sliceTop = d3 . select ( this ) ;
89
71
var slicePath = sliceTop . selectAll ( 'path.surface' ) . data ( [ pt ] ) ;
90
72
var hasHoverData = false ;
@@ -201,7 +183,7 @@ module.exports = function plot(gd, cdpie) {
201
183
pt . cyFinal = cy ;
202
184
203
185
function arc ( start , finish , cw , scale ) {
204
- return 'a' + ( scale * cd0 . r ) + ',' + ( scale * rSmall ) + ' ' + tiltAxis + ' ' +
186
+ return 'a' + ( scale * cd0 . r ) + ',' + ( scale * cd0 . r ) + ' 0 ' +
205
187
pt . largeArc + ( cw ? ' 1 ' : ' 0 ' ) +
206
188
( scale * ( finish [ 0 ] - start [ 0 ] ) ) + ',' + ( scale * ( finish [ 1 ] - start [ 1 ] ) ) ;
207
189
}
@@ -269,7 +251,6 @@ module.exports = function plot(gd, cdpie) {
269
251
. call ( svgTextUtils . convertToTspans , gd ) ;
270
252
271
253
// position the text relative to the slice
272
- // TODO: so far this only accounts for flat
273
254
var textBB = Drawing . bBox ( sliceText . node ( ) ) ;
274
255
var transform ;
275
256
@@ -566,7 +547,7 @@ function scootLabels(quadrants, trace) {
566
547
function scalePies ( cdpie , plotSize ) {
567
548
var scaleGroups = [ ] ;
568
549
569
- var pieBoxWidth , pieBoxHeight , i , j , cd0 , trace , tiltAxisRads ,
550
+ var pieBoxWidth , pieBoxHeight , i , j , cd0 , trace ,
570
551
maxPull , scaleGroup , minPxPerValUnit ;
571
552
572
553
// first figure out the center and maximum radius for each pie
@@ -575,7 +556,6 @@ function scalePies(cdpie, plotSize) {
575
556
trace = cd0 . trace ;
576
557
pieBoxWidth = plotSize . w * ( trace . domain . x [ 1 ] - trace . domain . x [ 0 ] ) ;
577
558
pieBoxHeight = plotSize . h * ( trace . domain . y [ 1 ] - trace . domain . y [ 0 ] ) ;
578
- tiltAxisRads = trace . tiltaxis * Math . PI / 180 ;
579
559
580
560
maxPull = trace . pull ;
581
561
if ( Array . isArray ( maxPull ) ) {
@@ -585,10 +565,7 @@ function scalePies(cdpie, plotSize) {
585
565
}
586
566
}
587
567
588
- cd0 . r = Math . min (
589
- pieBoxWidth / maxExtent ( trace . tilt , Math . sin ( tiltAxisRads ) , trace . depth ) ,
590
- pieBoxHeight / maxExtent ( trace . tilt , Math . cos ( tiltAxisRads ) , trace . depth )
591
- ) / ( 2 + 2 * maxPull ) ;
568
+ cd0 . r = Math . min ( pieBoxWidth , pieBoxHeight ) / ( 2 + 2 * maxPull ) ;
592
569
593
570
cd0 . cx = plotSize . l + plotSize . w * ( trace . domain . x [ 1 ] + trace . domain . x [ 0 ] ) / 2 ;
594
571
cd0 . cy = plotSize . t + plotSize . h * ( 2 - trace . domain . y [ 1 ] - trace . domain . y [ 0 ] ) / 2 ;
@@ -624,14 +601,12 @@ function scalePies(cdpie, plotSize) {
624
601
function setCoords ( cd ) {
625
602
var cd0 = cd [ 0 ] ;
626
603
var trace = cd0 . trace ;
627
- var tilt = trace . tilt ;
628
604
var currentAngle = trace . rotation * Math . PI / 180 ;
629
605
var angleFactor = 2 * Math . PI / cd0 . vTotal ;
630
606
var firstPt = 'px0' ;
631
607
var lastPt = 'px1' ;
632
608
633
- var tiltAxisRads , tiltAxisSin , tiltAxisCos , tiltRads , crossTilt ,
634
- inPlane , i , cdi , currentCoords ;
609
+ var i , cdi , currentCoords ;
635
610
636
611
if ( trace . direction === 'counterclockwise' ) {
637
612
for ( i = 0 ; i < cd . length ; i ++ ) {
@@ -645,26 +620,8 @@ function setCoords(cd) {
645
620
lastPt = 'px0' ;
646
621
}
647
622
648
- if ( tilt ) {
649
- tiltRads = tilt * Math . PI / 180 ;
650
- tiltAxisRads = trace . tiltaxis * Math . PI / 180 ;
651
- crossTilt = Math . sin ( tiltAxisRads ) * Math . cos ( tiltAxisRads ) ;
652
- inPlane = 1 - Math . cos ( tiltRads ) ;
653
- tiltAxisSin = Math . sin ( tiltAxisRads ) ;
654
- tiltAxisCos = Math . cos ( tiltAxisRads ) ;
655
- }
656
-
657
623
function getCoords ( angle ) {
658
- var xFlat = cd0 . r * Math . sin ( angle ) ;
659
- var yFlat = - cd0 . r * Math . cos ( angle ) ;
660
-
661
- if ( ! tilt ) return [ xFlat , yFlat ] ;
662
-
663
- return [
664
- xFlat * ( 1 - inPlane * tiltAxisSin * tiltAxisSin ) + yFlat * crossTilt * inPlane ,
665
- xFlat * crossTilt * inPlane + yFlat * ( 1 - inPlane * tiltAxisCos * tiltAxisCos ) ,
666
- Math . sin ( tiltRads ) * ( yFlat * tiltAxisCos - xFlat * tiltAxisSin )
667
- ] ;
624
+ return [ cd0 . r * Math . sin ( angle ) , - cd0 . r * Math . cos ( angle ) ] ;
668
625
}
669
626
670
627
currentCoords = getCoords ( currentAngle ) ;
@@ -687,11 +644,3 @@ function setCoords(cd) {
687
644
cdi . largeArc = ( cdi . v > cd0 . vTotal / 2 ) ? 1 : 0 ;
688
645
}
689
646
}
690
-
691
- function maxExtent ( tilt , tiltAxisFraction , depth ) {
692
- if ( ! tilt ) return 1 ;
693
- var sinTilt = Math . sin ( tilt * Math . PI / 180 ) ;
694
- return Math . max ( 0.01 , // don't let it go crazy if you tilt the pie totally on its side
695
- depth * sinTilt * Math . abs ( tiltAxisFraction ) +
696
- 2 * Math . sqrt ( 1 - sinTilt * sinTilt * tiltAxisFraction * tiltAxisFraction ) ) ;
697
- }
0 commit comments