1
+ /* eslint-disable react-hooks/exhaustive-deps */
1
2
/* eslint-disable max-len */
2
3
/* eslint-disable @typescript-eslint/ban-types */
3
4
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
11
12
/* eslint-disable no-plusplus */
12
13
/* eslint-disable func-names */
13
14
/* eslint-disable no-shadow */
14
- /* eslint-disable no-multi-spaces */
15
15
/* eslint-disable newline-per-chained-call */
16
16
/* eslint-disable object-curly-newline */
17
17
/* eslint-disable object-property-newline */
18
18
/* eslint-disable class-methods-use-this */
19
19
// eslint-disable-next-line object-curly-newline
20
- /* eslint-disable comma-dangle */
21
20
/* eslint-disable indent */
22
21
/* eslint-disable no-console */
23
22
@@ -32,10 +31,11 @@ interface PerfViewProps {
32
31
viewIndex :number ;
33
32
width : number ;
34
33
height : number ;
34
+ setNoRenderData : any ;
35
35
}
36
36
37
37
const PerfView = ( props :PerfViewProps ) => {
38
- const { snapshots, viewIndex, width, height } = props ;
38
+ const { snapshots, viewIndex, width, height, setNoRenderData } = props ;
39
39
const adjustedSize = Math . min ( width , height ) ;
40
40
const svgRef = useRef ( null ) ;
41
41
@@ -47,7 +47,7 @@ const PerfView = (props:PerfViewProps) => {
47
47
// Set up color scaling function
48
48
const colorScale = d3 . scaleLinear ( )
49
49
. domain ( [ 0 , 7 ] )
50
- . range ( [ 'hsl(200,60%,60%)' , 'hsl(255,30%,60 %)' ] )
50
+ . range ( [ 'hsl(200,60%,60%)' , 'hsl(255,30%,40 %)' ] )
51
51
. interpolate ( d3 . interpolateHcl ) ;
52
52
53
53
// Set up circle-packing layout function
@@ -60,6 +60,10 @@ const PerfView = (props:PerfViewProps) => {
60
60
. sort ( ( a :{ value :number } , b :{ value :number } ) => { return b . value - a . value ; } ) ) ;
61
61
} , [ adjustedSize ] ) ;
62
62
63
+ function handleNoRenderData ( isNoRenderData ) {
64
+ setNoRenderData ( isNoRenderData ) ;
65
+ }
66
+
63
67
// If indexToDisplay changes, clear old tree nodes
64
68
useEffect ( ( ) => {
65
69
while ( svgRef . current . hasChildNodes ( ) ) {
@@ -75,7 +79,7 @@ const PerfView = (props:PerfViewProps) => {
75
79
76
80
// Generate tree with our data
77
81
const packedRoot = packFunc ( snapshots [ indexToDisplay ] ) ;
78
- console . log ( 'PerfView -> packedRoot' , packedRoot ) ;
82
+ // console.log('PerfView -> packedRoot', packedRoot);
79
83
80
84
// Set initial focus to root node
81
85
let curFocus = packedRoot ;
@@ -84,10 +88,6 @@ const PerfView = (props:PerfViewProps) => {
84
88
let view ;
85
89
86
90
// 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)
91
91
const svg = d3 . select ( svgRef . current )
92
92
. attr ( 'viewBox' , `-${ adjustedSize / 2 } -${ adjustedSize / 2 } ${ width } ${ height } ` )
93
93
. on ( 'click' , ( ) => zoomToNode ( packedRoot ) ) ;
@@ -111,9 +111,12 @@ const PerfView = (props:PerfViewProps) => {
111
111
. enter ( ) . append ( 'text' )
112
112
. style ( 'fill-opacity' , ( d :{ parent :object } ) => ( d . parent === packedRoot ? 1 : 0 ) )
113
113
. 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 ) ;
115
118
return `${ d . data . name } : ${ Number . parseFloat ( d . data . componentData . actualDuration || 0 ) . toFixed ( 2 ) } ms` ;
116
- } ) ;
119
+ } ) ;
117
120
118
121
// Remove any unused nodes
119
122
label . exit ( ) . remove ( ) ;
@@ -150,7 +153,7 @@ const PerfView = (props:PerfViewProps) => {
150
153
151
154
curFocus = newFocus ;
152
155
}
153
- } , [ colorScale , packFunc , width , height , indexToDisplay , snapshots , adjustedSize ] ) ;
156
+ } , [ colorScale , packFunc , width , height , indexToDisplay , snapshots , adjustedSize , handleNoRenderData ] ) ;
154
157
155
158
return (
156
159
< div className = "perf-d3-container" >
@@ -161,6 +164,3 @@ const PerfView = (props:PerfViewProps) => {
161
164
} ;
162
165
163
166
export default PerfView ;
164
-
165
- // d3.quantize(d3.interpolateHcl('#60c96e', '#4d4193'), 10);
166
- // const colorScale = d3.scaleOrdinal(colorScheme);
0 commit comments