3
3
var d3 = require ( '@plotly/d3' ) ;
4
4
var Color = require ( '../../components/color' ) ;
5
5
var Lib = require ( '../../lib' ) ;
6
- var helpers = require ( '../sunburst/helpers' ) ;
7
6
var resizeText = require ( '../bar/uniform_text' ) . resizeText ;
8
7
9
8
function style ( gd ) {
@@ -18,72 +17,22 @@ function style(gd) {
18
17
gTrace . style ( 'opacity' , trace . opacity ) ;
19
18
20
19
gTrace . selectAll ( 'path.surface' ) . each ( function ( pt ) {
21
- d3 . select ( this ) . call ( styleOne , pt , trace , {
22
- hovered : false
23
- } ) ;
20
+ d3 . select ( this ) . call ( styleOne , pt , trace ) ;
24
21
} ) ;
25
22
} ) ;
26
23
}
27
24
28
- function styleOne ( s , pt , trace , opts ) {
29
- var hovered = ( opts || { } ) . hovered ;
25
+ function styleOne ( s , pt , trace ) {
30
26
var cdi = pt . data . data ;
27
+ var isLeaf = ! pt . children ;
31
28
var ptNumber = cdi . i ;
32
- var lineColor ;
33
- var lineWidth ;
34
- var fillColor = cdi . color ;
35
- var isRoot = helpers . isHierarchyRoot ( pt ) ;
36
- var opacity = 1 ;
37
-
38
- if ( hovered ) {
39
- lineColor = trace . _hovered . marker . line . color ;
40
- lineWidth = trace . _hovered . marker . line . width ;
41
- } else {
42
- if ( isRoot && fillColor === trace . root . color ) {
43
- opacity = 100 ;
44
- lineColor = 'rgba(0,0,0,0)' ;
45
- lineWidth = 0 ;
46
- } else {
47
- lineColor = Lib . castOption ( trace , ptNumber , 'marker.line.color' ) || Color . defaultLine ;
48
- lineWidth = Lib . castOption ( trace , ptNumber , 'marker.line.width' ) || 0 ;
49
-
50
- if ( ! trace . _hasColorscale && ! pt . onPathbar ) {
51
- var depthfade = trace . marker . depthfade ;
52
- if ( depthfade ) {
53
- var fadedColor = Color . combine ( Color . addOpacity ( trace . _backgroundColor , 0.75 ) , fillColor ) ;
54
- var n ;
55
-
56
- if ( depthfade === true ) {
57
- var maxDepth = helpers . getMaxDepth ( trace ) ;
58
- if ( isFinite ( maxDepth ) ) {
59
- if ( helpers . isLeaf ( pt ) ) {
60
- n = 0 ;
61
- } else {
62
- n = ( trace . _maxVisibleLayers ) - ( pt . data . depth - trace . _entryDepth ) ;
63
- }
64
- } else {
65
- n = pt . data . height + 1 ;
66
- }
67
- } else { // i.e. case of depthfade === 'reversed'
68
- n = pt . data . depth - trace . _entryDepth ;
69
- if ( ! trace . _atRootLevel ) n ++ ;
70
- }
71
-
72
- if ( n > 0 ) {
73
- for ( var i = 0 ; i < n ; i ++ ) {
74
- var ratio = 0.5 * i / n ;
75
- fillColor = Color . combine ( Color . addOpacity ( fadedColor , ratio ) , fillColor ) ;
76
- }
77
- }
78
- }
79
- }
80
- }
81
- }
29
+ var lineColor = Lib . castOption ( trace , ptNumber , 'marker.line.color' ) || Color . defaultLine ;
30
+ var lineWidth = Lib . castOption ( trace , ptNumber , 'marker.line.width' ) || 0 ;
82
31
83
32
s . style ( 'stroke-width' , lineWidth )
84
- . call ( Color . fill , fillColor )
33
+ . call ( Color . fill , cdi . color )
85
34
. call ( Color . stroke , lineColor )
86
- . style ( 'opacity' , opacity ) ;
35
+ . style ( 'opacity' , isLeaf ? trace . leaf . opacity : null ) ;
87
36
}
88
37
89
38
module . exports = {
0 commit comments