1+ /* eslint-disable react-hooks/exhaustive-deps */
12/* eslint-disable max-len */
23/* eslint-disable @typescript-eslint/ban-types */
34/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
1112/* eslint-disable no-plusplus */
1213/* eslint-disable func-names */
1314/* eslint-disable no-shadow */
14- /* eslint-disable no-multi-spaces */
1515/* eslint-disable newline-per-chained-call */
1616/* eslint-disable object-curly-newline */
1717/* eslint-disable object-property-newline */
1818/* eslint-disable class-methods-use-this */
1919// eslint-disable-next-line object-curly-newline
20- /* eslint-disable comma-dangle */
2120/* eslint-disable indent */
2221/* eslint-disable no-console */
2322
@@ -32,10 +31,11 @@ interface PerfViewProps {
3231 viewIndex :number ;
3332 width : number ;
3433 height : number ;
34+ setNoRenderData : any ;
3535}
3636
3737const PerfView = ( props :PerfViewProps ) => {
38- const { snapshots, viewIndex, width, height } = props ;
38+ const { snapshots, viewIndex, width, height, setNoRenderData } = props ;
3939 const adjustedSize = Math . min ( width , height ) ;
4040 const svgRef = useRef ( null ) ;
4141
@@ -47,7 +47,7 @@ const PerfView = (props:PerfViewProps) => {
4747 // Set up color scaling function
4848 const colorScale = d3 . scaleLinear ( )
4949 . domain ( [ 0 , 7 ] )
50- . range ( [ 'hsl(200,60%,60%)' , 'hsl(255,30%,60 %)' ] )
50+ . range ( [ 'hsl(200,60%,60%)' , 'hsl(255,30%,40 %)' ] )
5151 . interpolate ( d3 . interpolateHcl ) ;
5252
5353 // Set up circle-packing layout function
@@ -60,6 +60,10 @@ const PerfView = (props:PerfViewProps) => {
6060 . sort ( ( a :{ value :number } , b :{ value :number } ) => { return b . value - a . value ; } ) ) ;
6161 } , [ adjustedSize ] ) ;
6262
63+ function handleNoRenderData ( isNoRenderData ) {
64+ setNoRenderData ( isNoRenderData ) ;
65+ }
66+
6367 // If indexToDisplay changes, clear old tree nodes
6468 useEffect ( ( ) => {
6569 while ( svgRef . current . hasChildNodes ( ) ) {
@@ -75,7 +79,7 @@ const PerfView = (props:PerfViewProps) => {
7579
7680 // Generate tree with our data
7781 const packedRoot = packFunc ( snapshots [ indexToDisplay ] ) ;
78- console . log ( 'PerfView -> packedRoot' , packedRoot ) ;
82+ // console.log('PerfView -> packedRoot', packedRoot);
7983
8084 // Set initial focus to root node
8185 let curFocus = packedRoot ;
@@ -84,10 +88,6 @@ const PerfView = (props:PerfViewProps) => {
8488 let view ;
8589
8690 // Set up viewBox dimensions and onClick for parent svg
87-
88- // console.log("PerfView -> height", height)
89- // console.log("PerfView -> width", width)
90- // console.log("PerfView -> adjustedSize", adjustedSize)
9191 const svg = d3 . select ( svgRef . current )
9292 . attr ( 'viewBox' , `-${ adjustedSize / 2 } -${ adjustedSize / 2 } ${ width } ${ height } ` )
9393 . on ( 'click' , ( ) => zoomToNode ( packedRoot ) ) ;
@@ -111,9 +111,12 @@ const PerfView = (props:PerfViewProps) => {
111111 . enter ( ) . append ( 'text' )
112112 . style ( 'fill-opacity' , ( d :{ parent :object } ) => ( d . parent === packedRoot ? 1 : 0 ) )
113113 . style ( 'display' , ( d :{ parent ?:object } ) => ( d . parent === packedRoot ? 'inline' : 'none' ) )
114- . text ( ( d :{ data :{ name :string , componentData ?:{ actualDuration :any } } } ) => {
114+ . text ( ( d :{ data :{ name :string , componentData ?:{ actualDuration :any } } } ) => {
115+ // console.log("PerfView -> d.data", d.data);
116+ if ( ! d . data . componentData . actualDuration ) handleNoRenderData ( true ) ;
117+ else handleNoRenderData ( false ) ;
115118 return `${ d . data . name } : ${ Number . parseFloat ( d . data . componentData . actualDuration || 0 ) . toFixed ( 2 ) } ms` ;
116- } ) ;
119+ } ) ;
117120
118121 // Remove any unused nodes
119122 label . exit ( ) . remove ( ) ;
@@ -150,7 +153,7 @@ const PerfView = (props:PerfViewProps) => {
150153
151154 curFocus = newFocus ;
152155 }
153- } , [ colorScale , packFunc , width , height , indexToDisplay , snapshots , adjustedSize ] ) ;
156+ } , [ colorScale , packFunc , width , height , indexToDisplay , snapshots , adjustedSize , handleNoRenderData ] ) ;
154157
155158 return (
156159 < div className = "perf-d3-container" >
@@ -161,6 +164,3 @@ const PerfView = (props:PerfViewProps) => {
161164} ;
162165
163166export default PerfView ;
164-
165- // d3.quantize(d3.interpolateHcl('#60c96e', '#4d4193'), 10);
166- // const colorScale = d3.scaleOrdinal(colorScheme);
0 commit comments