66/* eslint-disable no-plusplus */
77/* eslint-disable func-names */
88/* eslint-disable no-shadow */
9- /* eslint-disable no-multi-spaces */
109/* eslint-disable newline-per-chained-call */
1110/* eslint-disable object-curly-newline */
1211/* eslint-disable object-property-newline */
1312/* eslint-disable class-methods-use-this */
1413// eslint-disable-next-line object-curly-newline
15- /* eslint-disable comma-dangle */
1614/* eslint-disable indent */
1715/* eslint-disable no-console */
1816
@@ -23,15 +21,16 @@ import { schemeSet1 as colorScheme } from 'd3';
2321// import { addNewSnapshots } from '../actions/actions.ts';
2422
2523interface PerfViewProps {
26- snapshots :any [ ] ;
27- viewIndex :number ;
24+ snapshots :any [ ] ;
25+ viewIndex :number ;
2826 width : number ;
2927 height : number ;
28+ setNoRenderData : any ;
3029}
3130
3231const PerfView = ( props :PerfViewProps ) => {
33- const { snapshots, viewIndex, width, height } = props
34- let adjustedSize = Math . min ( width , height ) ;
32+ const { snapshots, viewIndex, width, height, setNoRenderData } = props ;
33+ const adjustedSize = Math . min ( width , height ) ;
3534 const svgRef = useRef ( null ) ;
3635
3736 // Figure out which snapshot index to use
@@ -42,7 +41,7 @@ const PerfView = (props:PerfViewProps) => {
4241 // Set up color scaling function
4342 const colorScale = d3 . scaleLinear ( )
4443 . domain ( [ 0 , 7 ] )
45- . range ( [ 'hsl(200,60%,60%)' , 'hsl(255,30%,60 %)' ] )
44+ . range ( [ 'hsl(200,60%,60%)' , 'hsl(255,30%,40 %)' ] )
4645 . interpolate ( d3 . interpolateHcl ) ;
4746
4847 // Set up circle-packing layout function
@@ -55,6 +54,10 @@ const PerfView = (props:PerfViewProps) => {
5554 . sort ( ( a :{ value :number } , b :{ value :number } ) => { return b . value - a . value ; } ) ) ;
5655 } , [ adjustedSize ] ) ;
5756
57+ function handleNoRenderData ( isNoRenderData ) {
58+ setNoRenderData ( isNoRenderData ) ;
59+ }
60+
5861 // If indexToDisplay changes, clear old tree nodes
5962 useEffect ( ( ) => {
6063 while ( svgRef . current . hasChildNodes ( ) ) {
@@ -70,19 +73,15 @@ const PerfView = (props:PerfViewProps) => {
7073
7174 // Generate tree with our data
7275 const packedRoot = packFunc ( snapshots [ indexToDisplay ] ) ;
73- console . log ( 'PerfView -> packedRoot' , packedRoot ) ;
76+ // console.log('PerfView -> packedRoot', packedRoot);
7477
7578 // Set initial focus to root node
7679 let curFocus = packedRoot ;
7780
7881 // View [x, y, r]
7982 let view ;
8083
81- // Set up viewBox dimensions and onClick for parent svg
82-
83- // console.log("PerfView -> height", height)
84- // console.log("PerfView -> width", width)
85- // console.log("PerfView -> adjustedSize", adjustedSize)
84+ // Set up viewBox dimensions and onClick for parent svg
8685 const svg = d3 . select ( svgRef . current )
8786 . attr ( 'viewBox' , `-${ adjustedSize / 2 } -${ adjustedSize / 2 } ${ width } ${ height } ` )
8887 . on ( 'click' , ( ) => zoomToNode ( packedRoot ) ) ;
@@ -106,8 +105,12 @@ const PerfView = (props:PerfViewProps) => {
106105 . enter ( ) . append ( 'text' )
107106 . style ( 'fill-opacity' , ( d :{ parent :object } ) => ( d . parent === packedRoot ? 1 : 0 ) )
108107 . style ( 'display' , ( d :{ parent ?:object } ) => ( d . parent === packedRoot ? 'inline' : 'none' ) )
109- . text ( ( d :{ data :{ name :string , componentData ?:{ actualDuration :any } } } ) => {
110- return `${ d . data . name } : ${ Number . parseFloat ( d . data . componentData . actualDuration || 0 ) . toFixed ( 2 ) } ms` } ) ;
108+ . text ( ( d :{ data :{ name :string , componentData ?:{ actualDuration :any } } } ) => {
109+ // console.log("PerfView -> d.data", d.data);
110+ if ( ! d . data . componentData . actualDuration ) handleNoRenderData ( true ) ;
111+ else handleNoRenderData ( false ) ;
112+ return `${ d . data . name } : ${ Number . parseFloat ( d . data . componentData . actualDuration || 0 ) . toFixed ( 2 ) } ms` ;
113+ } ) ;
111114
112115 // Remove any unused nodes
113116 label . exit ( ) . remove ( ) ;
@@ -154,8 +157,4 @@ const PerfView = (props:PerfViewProps) => {
154157 ) ;
155158} ;
156159
157- export default PerfView ;
158-
159-
160- // d3.quantize(d3.interpolateHcl('#60c96e', '#4d4193'), 10);
161- // const colorScale = d3.scaleOrdinal(colorScheme);
160+ export default PerfView ;
0 commit comments