@@ -42,9 +42,10 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
4242 const packFunc = useCallback ( data => {
4343 return d3 . pack ( )
4444 . size ( [ width , height ] )
45+ // .radius(d => { return d.r; })
4546 . 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 ; } ) ) ;
4849 } , [ width , height ] ) ;
4950
5051 // If indexToDisplay changes, clear old tree nodes
@@ -55,12 +56,14 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
5556 } , [ indexToDisplay , svgRef ] ) ;
5657
5758 useEffect ( ( ) => {
58-
59+ // console.log(`***** useEffect - MAIN -> snapshots[${indexToDisplay}]`, snapshots[indexToDisplay]);
60+
5961 // Error, no App-level component present
6062 if ( snapshots [ indexToDisplay ] . children . length < 1 ) return ;
6163
6264 // Generate tree with our data
6365 const packedRoot = packFunc ( snapshots [ indexToDisplay ] ) ;
66+ console . log ( 'PerfView -> packedRoot' , packedRoot ) ;
6467
6568 // Set initial focus to root node
6669 let curFocus = packedRoot ;
@@ -80,13 +83,12 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
8083 . enter ( ) . append ( 'circle' )
8184 . attr ( 'fill' , d => ( d . children ? colorScale ( d . depth ) : 'white' ) )
8285 . attr ( 'pointer-events' , d => ( ! d . children ? 'none' : null ) )
83- . on ( 'mouseover' , ( ) => d3 . select ( this ) . attr ( 'stroke' , '#000' ) )
84- . on ( 'mouseout' , ( ) => d3 . select ( this ) . attr ( 'stroke' , null ) )
86+ . on ( 'mouseover' , function ( ) { d3 . select ( this ) . attr ( 'stroke' , '#000' ) ; } )
87+ . on ( 'mouseout' , function ( ) { d3 . select ( this ) . attr ( 'stroke' , null ) ; } )
8588 . on ( 'click' , d => curFocus !== d && ( zoomToNode ( d ) , d3 . event . stopPropagation ( ) ) ) ;
8689
8790 // Generate text labels. Set (only) root to visible initially
8891 const label = svg . append ( 'g' )
89- // .style('fill', 'rgb(231, 231, 231)')
9092 . attr ( 'class' , 'perf-chart-labels' )
9193 . selectAll ( 'text' )
9294 . data ( packedRoot . descendants ( ) )
@@ -133,11 +135,16 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
133135 }
134136 } , [ colorScale , packFunc , width , height , indexToDisplay , snapshots ] ) ;
135137
136- return < svg className = "perfContainer" ref = { svgRef } /> ;
138+ return (
139+ < div className = "perf-d3-container" >
140+ < svg className = "perf-d3-svg" ref = { svgRef } />
141+ { /* <span>TEST</span> */ }
142+ </ div >
143+ ) ;
137144} ;
138145
139146export default PerfView ;
140147
141148
142149 // d3.quantize(d3.interpolateHcl('#60c96e', '#4d4193'), 10);
143- // const colorScale = d3.scaleOrdinal(colorScheme);
150+ // const colorScale = d3.scaleOrdinal(colorScheme);
0 commit comments