6
6
/* eslint-disable no-plusplus */
7
7
/* eslint-disable func-names */
8
8
/* eslint-disable no-shadow */
9
- /* eslint-disable no-multi-spaces */
10
9
/* eslint-disable newline-per-chained-call */
11
10
/* eslint-disable object-curly-newline */
12
11
/* eslint-disable object-property-newline */
13
12
/* eslint-disable class-methods-use-this */
14
13
// eslint-disable-next-line object-curly-newline
15
- /* eslint-disable comma-dangle */
16
14
/* eslint-disable indent */
17
15
/* eslint-disable no-console */
18
16
@@ -23,15 +21,16 @@ import { schemeSet1 as colorScheme } from 'd3';
23
21
// import { addNewSnapshots } from '../actions/actions.ts';
24
22
25
23
interface PerfViewProps {
26
- snapshots :any [ ] ;
27
- viewIndex :number ;
24
+ snapshots :any [ ] ;
25
+ viewIndex :number ;
28
26
width : number ;
29
27
height : number ;
28
+ setNoRenderData : any ;
30
29
}
31
30
32
31
const 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 ) ;
35
34
const svgRef = useRef ( null ) ;
36
35
37
36
// Figure out which snapshot index to use
@@ -42,7 +41,7 @@ const PerfView = (props:PerfViewProps) => {
42
41
// Set up color scaling function
43
42
const colorScale = d3 . scaleLinear ( )
44
43
. domain ( [ 0 , 7 ] )
45
- . range ( [ 'hsl(200,60%,60%)' , 'hsl(255,30%,60 %)' ] )
44
+ . range ( [ 'hsl(200,60%,60%)' , 'hsl(255,30%,40 %)' ] )
46
45
. interpolate ( d3 . interpolateHcl ) ;
47
46
48
47
// Set up circle-packing layout function
@@ -55,6 +54,10 @@ const PerfView = (props:PerfViewProps) => {
55
54
. sort ( ( a :{ value :number } , b :{ value :number } ) => { return b . value - a . value ; } ) ) ;
56
55
} , [ adjustedSize ] ) ;
57
56
57
+ function handleNoRenderData ( isNoRenderData ) {
58
+ setNoRenderData ( isNoRenderData ) ;
59
+ }
60
+
58
61
// If indexToDisplay changes, clear old tree nodes
59
62
useEffect ( ( ) => {
60
63
while ( svgRef . current . hasChildNodes ( ) ) {
@@ -70,19 +73,15 @@ const PerfView = (props:PerfViewProps) => {
70
73
71
74
// Generate tree with our data
72
75
const packedRoot = packFunc ( snapshots [ indexToDisplay ] ) ;
73
- console . log ( 'PerfView -> packedRoot' , packedRoot ) ;
76
+ // console.log('PerfView -> packedRoot', packedRoot);
74
77
75
78
// Set initial focus to root node
76
79
let curFocus = packedRoot ;
77
80
78
81
// View [x, y, r]
79
82
let view ;
80
83
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
86
85
const svg = d3 . select ( svgRef . current )
87
86
. attr ( 'viewBox' , `-${ adjustedSize / 2 } -${ adjustedSize / 2 } ${ width } ${ height } ` )
88
87
. on ( 'click' , ( ) => zoomToNode ( packedRoot ) ) ;
@@ -106,8 +105,12 @@ const PerfView = (props:PerfViewProps) => {
106
105
. enter ( ) . append ( 'text' )
107
106
. style ( 'fill-opacity' , ( d :{ parent :object } ) => ( d . parent === packedRoot ? 1 : 0 ) )
108
107
. 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
+ } ) ;
111
114
112
115
// Remove any unused nodes
113
116
label . exit ( ) . remove ( ) ;
@@ -154,8 +157,4 @@ const PerfView = (props:PerfViewProps) => {
154
157
) ;
155
158
} ;
156
159
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