@@ -86,139 +86,138 @@ const BarGraph = (props) => {
86
86
} ) ;
87
87
88
88
// setting max dimensions and scale ranges
89
-
90
89
const xMax = width - margin . left - margin . right ;
91
90
const yMax = height - margin . top - 150 ;
92
91
snapshotIdScale . rangeRound ( [ 0 , xMax ] ) ;
93
92
renderingScale . range ( [ yMax , 0 ] ) ;
94
- return (
95
- < div >
96
- < svg ref = { containerRef } width = { width } height = { height } >
97
- { }
98
- < rect
99
- x = { 0 }
100
- y = { 0 }
101
- width = { width }
102
- height = { height }
103
- fill = { background }
104
- rx = { 14 }
105
- />
106
- < Grid
107
- top = { margin . top }
108
- left = { margin . left }
109
- xScale = { snapshotIdScale }
110
- yScale = { renderingScale }
111
- width = { xMax }
112
- height = { yMax }
113
- stroke = "black"
114
- strokeOpacity = { 0.1 }
115
- xOffset = { snapshotIdScale . bandwidth ( ) / 2 }
116
- />
117
- < Group top = { margin . top } left = { margin . left } >
118
- < BarStack
119
- data = { data . barStack }
120
- keys = { keys }
121
- x = { getSnapshotId }
93
+ return (
94
+ < div >
95
+ < svg ref = { containerRef } width = { width } height = { height } >
96
+ { }
97
+ < rect
98
+ x = { 0 }
99
+ y = { 0 }
100
+ width = { width }
101
+ height = { height }
102
+ fill = { background }
103
+ rx = { 14 }
104
+ />
105
+ < Grid
106
+ top = { margin . top }
107
+ left = { margin . left }
122
108
xScale = { snapshotIdScale }
123
109
yScale = { renderingScale }
124
- color = { colorScale }
110
+ width = { xMax }
111
+ height = { yMax }
112
+ stroke = "black"
113
+ strokeOpacity = { 0.1 }
114
+ xOffset = { snapshotIdScale . bandwidth ( ) / 2 }
115
+ />
116
+ < Group top = { margin . top } left = { margin . left } >
117
+ < BarStack
118
+ data = { data . barStack }
119
+ keys = { keys }
120
+ x = { getSnapshotId }
121
+ xScale = { snapshotIdScale }
122
+ yScale = { renderingScale }
123
+ color = { colorScale }
124
+ >
125
+ { barStacks =>
126
+ barStacks . map ( barStack =>
127
+ barStack . bars . map ( ( ( bar , idx ) => {
128
+ // hides new components if components don't exist in previous snapshots
129
+ if ( Number . isNaN ( bar . bar [ 1 ] ) || bar . height < 0 ) {
130
+ bar . height = 0 ;
131
+ }
132
+ return (
133
+ < rect
134
+ key = { `bar-stack-${ barStack . index } -${ bar . index } ` }
135
+ x = { bar . x }
136
+ y = { bar . y }
137
+ height = { bar . height === 0 ? null : bar . height }
138
+ width = { bar . width }
139
+ fill = { bar . color }
140
+ /* TIP TOOL EVENT HANDLERS */
141
+ // Hides tool tip once cursor moves off the current rect
142
+ onMouseLeave = { ( ) => {
143
+ dispatch ( onHoverExit ( data . componentData [ bar . key ] . rtid ) ,
144
+ tooltipTimeout = window . setTimeout ( ( ) => {
145
+ hideTooltip ( )
146
+ } , 300 ) )
147
+ } }
148
+ // Cursor position in window updates position of the tool tip
149
+ onMouseMove = { event => {
150
+ dispatch ( onHover ( data . componentData [ bar . key ] . rtid ) )
151
+ if ( tooltipTimeout ) clearTimeout ( tooltipTimeout ) ;
152
+ const top = event . clientY - margin . top - bar . height ;
153
+ const left = bar . x + bar . width / 2 ;
154
+ showTooltip ( {
155
+ tooltipData : bar ,
156
+ tooltipTop : top ,
157
+ tooltipLeft : left ,
158
+ } ) ;
159
+ } }
160
+ />
161
+ ) } ) ) )
162
+ }
163
+ </ BarStack >
164
+ </ Group >
165
+ < AxisLeft
166
+ top = { margin . top }
167
+ left = { margin . left }
168
+ scale = { renderingScale }
169
+ stroke = { axisColor }
170
+ tickStroke = { axisColor }
171
+ strokeWidth = { 2 }
172
+ tickLabelProps = { ( ) => ( {
173
+ fill : 'rgb(231, 231, 231)' ,
174
+ fontSize : 11 ,
175
+ verticalAnchor : 'middle' ,
176
+ textAnchor : 'end' ,
177
+ } ) }
178
+ />
179
+ < AxisBottom
180
+ top = { yMax + margin . top }
181
+ left = { margin . left }
182
+ scale = { snapshotIdScale }
183
+ stroke = { axisColor }
184
+ tickStroke = { axisColor }
185
+ strokeWidth = { 2 }
186
+ tickLabelProps = { ( ) => ( {
187
+ fill : 'rgb(231, 231, 231)' ,
188
+ fontSize : 11 ,
189
+ textAnchor : 'middle' ,
190
+ } ) }
191
+ />
192
+ < Text x = { - xMax / 2 } y = "15" transform = "rotate(-90)" fontSize = { 12 } fill = "#FFFFFF" > Rendering Time (ms) </ Text >
193
+ < Text x = { xMax / 2 } y = { yMax + 65 } fontSize = { 12 } fill = "#FFFFFF" > Snapshot Id </ Text >
194
+ </ svg >
195
+ { /* FOR HOVER OVER DISPLAY */ }
196
+ { tooltipOpen && tooltipData && (
197
+ < TooltipInPortal
198
+ key = { Math . random ( ) } // update tooltip bounds each render
199
+ top = { tooltipTop }
200
+ left = { tooltipLeft }
201
+ style = { tooltipStyles }
125
202
>
126
- { barStacks =>
127
- barStacks . map ( barStack =>
128
- barStack . bars . map ( ( ( bar , idx ) => {
129
- // hides new components if components don't exist in previous snapshots
130
- if ( Number . isNaN ( bar . bar [ 1 ] ) || bar . height < 0 ) {
131
- bar . height = 0 ;
132
- }
133
- return (
134
- < rect
135
- key = { `bar-stack-${ barStack . index } -${ bar . index } ` }
136
- x = { bar . x }
137
- y = { bar . y }
138
- height = { bar . height === 0 ? null : bar . height }
139
- width = { bar . width }
140
- fill = { bar . color }
141
- /* TIP TOOL EVENT HANDLERS */
142
- // Hides tool tip once cursor moves off the current rect
143
- onMouseLeave = { ( ) => {
144
- dispatch ( onHoverExit ( data . componentData [ bar . key ] . rtid ) ,
145
- tooltipTimeout = window . setTimeout ( ( ) => {
146
- hideTooltip ( )
147
- } , 300 ) )
148
- } }
149
- // Cursor position in window updates position of the tool tip
150
- onMouseMove = { event => {
151
- dispatch ( onHover ( data . componentData [ bar . key ] . rtid ) )
152
- if ( tooltipTimeout ) clearTimeout ( tooltipTimeout ) ;
153
- const top = event . clientY - margin . top - bar . height ;
154
- const left = bar . x + bar . width / 2 ;
155
- showTooltip ( {
156
- tooltipData : bar ,
157
- tooltipTop : top ,
158
- tooltipLeft : left ,
159
- } ) ;
160
- } }
161
- />
162
- ) } ) ) )
163
- }
164
- </ BarStack >
165
- </ Group >
166
- < AxisLeft
167
- top = { margin . top }
168
- left = { margin . left }
169
- scale = { renderingScale }
170
- stroke = { axisColor }
171
- tickStroke = { axisColor }
172
- strokeWidth = { 2 }
173
- tickLabelProps = { ( ) => ( {
174
- fill : 'rgb(231, 231, 231)' ,
175
- fontSize : 11 ,
176
- verticalAnchor : 'middle' ,
177
- textAnchor : 'end' ,
178
- } ) }
179
- />
180
- < AxisBottom
181
- top = { yMax + margin . top }
182
- left = { margin . left }
183
- scale = { snapshotIdScale }
184
- stroke = { axisColor }
185
- tickStroke = { axisColor }
186
- strokeWidth = { 2 }
187
- tickLabelProps = { ( ) => ( {
188
- fill : 'rgb(231, 231, 231)' ,
189
- fontSize : 11 ,
190
- textAnchor : 'middle' ,
191
- } ) }
192
- />
193
- < Text x = { - xMax / 2 } y = "15" transform = "rotate(-90)" fontSize = { 12 } fill = "#FFFFFF" > Rendering Time (ms) </ Text >
194
- < Text x = { xMax / 2 } y = { yMax + 65 } fontSize = { 12 } fill = "#FFFFFF" > Snapshot Id </ Text >
195
- </ svg >
196
- { /* FOR HOVER OVER DISPLAY */ }
197
- { tooltipOpen && tooltipData && (
198
- < TooltipInPortal
199
- key = { Math . random ( ) } // update tooltip bounds each render
200
- top = { tooltipTop }
201
- left = { tooltipLeft }
202
- style = { tooltipStyles }
203
- >
204
- < div style = { { color : colorScale ( tooltipData . key ) } } >
205
- { ' ' }
206
- < strong > { tooltipData . key } </ strong >
207
- { ' ' }
208
- </ div >
209
- < div > { data . componentData [ tooltipData . key ] . stateType } </ div >
210
- < div >
211
- { ' ' }
212
- { formatRenderTime ( tooltipData . bar . data [ tooltipData . key ] ) }
203
+ < div style = { { color : colorScale ( tooltipData . key ) } } >
213
204
{ ' ' }
214
- </ div >
215
- < div >
205
+ < strong > { tooltipData . key } </ strong >
216
206
{ ' ' }
217
- < small > { formatSnapshotId ( getSnapshotId ( tooltipData . bar . data ) ) } </ small >
218
- </ div >
219
- </ TooltipInPortal >
220
- ) }
221
- </ div >
207
+ </ div >
208
+ < div > { data . componentData [ tooltipData . key ] . stateType } </ div >
209
+ < div >
210
+ { ' ' }
211
+ { formatRenderTime ( tooltipData . bar . data [ tooltipData . key ] ) }
212
+ { ' ' }
213
+ </ div >
214
+ < div >
215
+ { ' ' }
216
+ < small > { formatSnapshotId ( getSnapshotId ( tooltipData . bar . data ) ) } </ small >
217
+ </ div >
218
+ </ TooltipInPortal >
219
+ ) }
220
+ </ div >
222
221
) } ;
223
222
224
223
export default BarGraph ;
0 commit comments