@@ -11,26 +11,26 @@ import React, { useEffect, useRef } from 'react';
11
11
import * as d3 from 'd3' ;
12
12
import { addNewSnapshots } from '../actions/actions' ;
13
13
14
- const chartData = {
15
- name : 'App' ,
16
- actualDuration : 35000 ,
17
- value : 17010 ,
18
- children : [
19
- { name : 'DisplayPanel' , actualDuration : 35000 , value : 17010 } ,
20
- { name : 'AltDisplay' , actualDuration : 35000 , value : 5842 } ,
21
- { name : 'MarketSContainer' , actualDuration : 35000 , value : 1041 } ,
22
- { name : 'MainSlider' , actualDuration : 35000 , value : 5176 } ,
23
- ] ,
24
- } ;
14
+ // const chartData = {
15
+ // name: 'App',
16
+ // actualDuration: 35000,
17
+ // value: 17010,
18
+ // children: [
19
+ // { name: 'DisplayPanel', actualDuration: 35000, value: 17010 },
20
+ // { name: 'AltDisplay', actualDuration: 35000, value: 5842 },
21
+ // { name: 'MarketSContainer', actualDuration: 35000, value: 1041 },
22
+ // { name: 'MainSlider', actualDuration: 35000, value: 5176 },
23
+ // ],
24
+ // };
25
25
26
26
const PerfView = ( {
27
27
width = 200 ,
28
28
height = 200 ,
29
- // snapshots
29
+ snapshots
30
30
} ) => {
31
31
// const chartData = snapshots;
32
- // const chartData = snapshots[snapshots.length - 1].children[0] ;
33
- // console.log("snapshots", snapshots) ;
32
+ console . log ( "snapshots" , snapshots ) ;
33
+ const chartData = snapshots [ snapshots . length - 1 ] . children [ 0 ] ;
34
34
console . log ( "chartData" , chartData ) ;
35
35
36
36
const svgRef = useRef ( null ) ;
@@ -45,8 +45,8 @@ const PerfView = ({
45
45
const packFunc = data => d3 . pack ( )
46
46
. size ( [ width , height ] )
47
47
. padding ( 3 ) ( d3 . hierarchy ( data )
48
- . sum ( d => d . actualDuration )
49
- . sort ( ( a , b ) => b . actualDuration - a . actualDuration ) ) ;
48
+ . sum ( d => d . componentData . actualDuration )
49
+ . sort ( ( a , b ) => b . componentData . actualDuration - a . componentData . actualDuration ) ) ;
50
50
51
51
useEffect ( ( ) => {
52
52
const packedRoot = packFunc ( chartData ) ;
@@ -80,7 +80,7 @@ const PerfView = ({
80
80
. append ( 'text' )
81
81
. style ( 'fill-opacity' , d => ( d . parent === packedRoot ? 1 : 0 ) )
82
82
. style ( 'display' , d => ( d . parent === packedRoot ? 'inline' : 'none' ) )
83
- . text ( d => `${ d . name } : ${ Number . parseFloat ( d . actualDuration ) . toFixed ( 2 ) } ms` ) ;
83
+ . text ( d => `${ d . data . name } : ${ Number . parseFloat ( d . data . actualDuration ) . toFixed ( 2 ) } ms` ) ;
84
84
85
85
console . log ( 'PerfView -> node' , node ) ;
86
86
zoomTo ( [ packedRoot . x , packedRoot . y , packedRoot . r * 2 ] ) ;
0 commit comments