@@ -42,9 +42,10 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
42
42
const packFunc = useCallback ( data => {
43
43
return d3 . pack ( )
44
44
. size ( [ width , height ] )
45
+ . radius ( d => { return d . r ; } )
45
46
. padding ( 3 ) ( d3 . hierarchy ( data )
46
- . sum ( d => { return d . componentData . actualDuration || 0 ; } )
47
- . sort ( ( a , b ) => { return b . value - a . value ; } ) ) ;
47
+ . sum ( d => { return d . componentData . actualDuration || 0 ; } )
48
+ . sort ( ( a , b ) => { return b . value - a . value ; } ) ) ;
48
49
} , [ width , height ] ) ;
49
50
50
51
// If indexToDisplay changes, clear old tree nodes
@@ -56,13 +57,14 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
56
57
} , [ indexToDisplay , svgRef ] ) ;
57
58
58
59
useEffect ( ( ) => {
59
- // console.log(`***** useEffect - MAIN -> snapshots[${indexToDisplay}]`, snapshots[indexToDisplay]);
60
-
60
+ console . log ( `***** useEffect - MAIN -> snapshots[${ indexToDisplay } ]` , snapshots [ indexToDisplay ] ) ;
61
+
61
62
// Error, no App-level component present
62
63
if ( snapshots [ indexToDisplay ] . children . length < 1 ) return ;
63
64
64
65
// Generate tree with our data
65
66
const packedRoot = packFunc ( snapshots [ indexToDisplay ] ) ;
67
+ console . log ( 'PerfView -> packedRoot' , packedRoot ) ;
66
68
67
69
// Set initial focus to root node
68
70
let curFocus = packedRoot ;
@@ -82,13 +84,12 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
82
84
. enter ( ) . append ( 'circle' )
83
85
. attr ( 'fill' , d => ( d . children ? colorScale ( d . depth ) : 'white' ) )
84
86
. attr ( 'pointer-events' , d => ( ! d . children ? 'none' : null ) )
85
- . on ( 'mouseover' , ( ) => d3 . select ( this ) . attr ( 'stroke' , '#000' ) )
86
- . on ( 'mouseout' , ( ) => d3 . select ( this ) . attr ( 'stroke' , null ) )
87
+ . on ( 'mouseover' , function ( ) { d3 . select ( this ) . attr ( 'stroke' , '#000' ) ; } )
88
+ . on ( 'mouseout' , function ( ) { d3 . select ( this ) . attr ( 'stroke' , null ) ; } )
87
89
. on ( 'click' , d => curFocus !== d && ( zoomToNode ( d ) , d3 . event . stopPropagation ( ) ) ) ;
88
90
89
91
// Generate text labels. Set (only) root to visible initially
90
92
const label = svg . append ( 'g' )
91
- // .style('fill', 'rgb(231, 231, 231)')
92
93
. attr ( 'class' , 'perf-chart-labels' )
93
94
. selectAll ( 'text' )
94
95
. data ( packedRoot . descendants ( ) )
@@ -107,7 +108,7 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
107
108
108
109
// Zoom/relocated nodes and labels based on dimensions given [x, y, r]
109
110
function zoomViewArea ( newXYR ) {
110
- console . log ( " zoomTo -> newXYR" , newXYR ) ;
111
+ // console.log(' zoomTo -> newXYR' , newXYR);
111
112
const k = width / newXYR [ 2 ] ;
112
113
view = newXYR ;
113
114
label . attr ( 'transform' , d => `translate(${ ( d . x - newXYR [ 0 ] ) * k } ,${ ( d . y - newXYR [ 1 ] ) * k } )` ) ;
@@ -144,4 +145,4 @@ export default PerfView;
144
145
145
146
146
147
// d3.quantize(d3.interpolateHcl('#60c96e', '#4d4193'), 10);
147
- // const colorScale = d3.scaleOrdinal(colorScheme);
148
+ // const colorScale = d3.scaleOrdinal(colorScheme);
0 commit comments