@@ -105,15 +105,17 @@ const BarGraphComparison = (props) => {
105
105
const formatRenderTime = ( time ) => `${ time } ms ` ;
106
106
const getCurrentTab = ( storedSeries ) => storedSeries . currentTab ;
107
107
// create visualization SCALES with cleaned data
108
- //const xAxisPoints = [...titleFilter(comparison).map(getTabID), currentTab];
109
- //the domain array elements will place the bars along the x-axis
110
- const xAxisPoints = [ 'currentTab' , 'comparison' ] ; //[1.0.,2.0]
111
- //{ currentTab : 1 }, {currentTab : 2 }
108
+ // the domain array/xAxisPoints elements will place the bars along the x-axis
109
+ const xAxisPoints = [ 'currentTab' , 'comparison' ] ;
112
110
const snapshotIdScale = scaleBand < string > ( {
113
111
domain : xAxisPoints ,
114
112
padding : 0.2 ,
115
113
} ) ;
116
- // calculateMax
114
+ // This function will iterate through the snapshots of the series,
115
+ // and grab the highest render times (sum of all component times).
116
+ // We'll then use it in the renderingScale function and compare
117
+ // with the render time of the current tab.
118
+ // The max render time will determine the Y-axis's highest number.
117
119
const calculateMaxTotalRender = ( series ) => {
118
120
const currentSeriesBarStacks = ! comparison [ series ]
119
121
? [ ]
@@ -128,11 +130,13 @@ const BarGraphComparison = (props) => {
128
130
return currentMax ;
129
131
} ;
130
132
133
+ // the domain array on rendering scale will set the coordinates for Y-aix points.
131
134
const renderingScale = scaleLinear < number > ( {
132
135
domain : [ 0 , Math . max ( calculateMaxTotalRender ( series ) , data . maxTotalRender ) ] ,
133
136
nice : true ,
134
137
} ) ;
135
-
138
+ // the domain array will assign each key(component on test app) a different color
139
+ // and use range to set the color scheme each bar
136
140
const colorScale = scaleOrdinal < string > ( {
137
141
domain : keys ,
138
142
range : schemeSet3 ,
@@ -144,7 +148,7 @@ const BarGraphComparison = (props) => {
144
148
snapshotIdScale . rangeRound ( [ 0 , xMax ] ) ;
145
149
renderingScale . range ( [ yMax , 0 ] ) ;
146
150
147
- // Dropdown to select series.
151
+ // useStyles will change the styling on save series dropdown feature
148
152
const useStyles = makeStyles ( ( theme ) => ( {
149
153
formControl : {
150
154
margin : theme . spacing ( 1 ) ,
@@ -198,37 +202,37 @@ const BarGraphComparison = (props) => {
198
202
e . target . classList . add ( 'animate' ) ;
199
203
e . target . innerHTML = 'Deleted!' ;
200
204
setTimeout ( function ( ) {
201
- e . target . innerHTML = 'Clear Series' ;
205
+ e . target . innerHTML = 'Clear All Series' ;
202
206
e . target . classList . remove ( 'animate' ) ;
203
207
} , 1000 ) ;
204
208
} ;
205
209
const classname = document . getElementsByClassName ( 'delete-button' ) ;
206
210
for ( let i = 0 ; i < classname . length ; i ++ ) {
207
211
classname [ i ] . addEventListener ( 'click' , animateButton , false ) ;
208
212
}
209
- //console.log('set x on current bar', setXpointsCurrentTab());
210
213
return (
211
214
< div >
212
- < div className = ' series-options-container' >
213
- < div className = ' snapshotId-header' >
215
+ < div className = " series-options-container" >
216
+ < div className = " snapshotId-header" >
214
217
{ ' ' }
215
218
Snapshot ID: { currentIndex + 1 } { ' ' }
216
219
</ div >
217
220
218
- < div className = ' dropdown-and-delete-series-container' >
221
+ < div className = " dropdown-and-delete-series-container" >
219
222
< button
220
- className = ' delete-button'
223
+ className = " delete-button"
221
224
onClick = { ( e ) => {
222
225
dispatch ( deleteSeries ( ) ) ;
223
226
} }
224
227
>
225
228
Clear All Series
226
229
</ button >
227
- < FormControl variant = 'outlined' className = { classes . formControl } >
230
+ < h4 style = { { padding : '0 1rem' } } > Compare with: </ h4 >
231
+ < FormControl variant = "outlined" className = { classes . formControl } >
228
232
< Select
229
233
style = { { color : 'white' } }
230
- labelId = ' simple-select-outlined-label'
231
- id = ' simple-select-outlined'
234
+ labelId = " simple-select-outlined-label"
235
+ id = " simple-select-outlined"
232
236
className = { classes . select }
233
237
open = { open }
234
238
onClose = { handleClose }
@@ -267,13 +271,13 @@ const BarGraphComparison = (props) => {
267
271
yScale = { renderingScale }
268
272
width = { xMax }
269
273
height = { yMax }
270
- stroke = ' black'
274
+ stroke = " black"
271
275
strokeOpacity = { 0.1 }
272
276
xOffset = { snapshotIdScale . bandwidth ( ) / 2 }
273
277
/>
274
278
< Group top = { margin . top } left = { margin . left } >
275
279
< BarStack
276
- // OG Barstack
280
+ // Current Tab bar stack.
277
281
data = { setXpointsCurrentTab ( ) }
278
282
keys = { keys }
279
283
x = { getCurrentTab }
@@ -283,6 +287,11 @@ const BarGraphComparison = (props) => {
283
287
>
284
288
{ ( barStacks ) =>
285
289
barStacks . map ( ( barStack , idx ) => {
290
+ // Uses map method to iterate through all components,
291
+ // creating a rect component (from visx) for each iteration.
292
+ // height/width/etc. are calculated by visx.
293
+ // to set X and Y scale, it will used the passed in function and
294
+ // will run it on the array thats outputted by data
286
295
const bar = barStack . bars [ currentIndex ] ;
287
296
if ( Number . isNaN ( bar . bar [ 1 ] ) || bar . height < 0 ) {
288
297
bar . height = 0 ;
@@ -323,7 +332,9 @@ const BarGraphComparison = (props) => {
323
332
}
324
333
</ BarStack >
325
334
< BarStack
326
- // Comparison Barstack
335
+ // Comparison Barstack (populates based on series selected)
336
+ //to set X and Y scale, it will used the passed in function and
337
+ // will run it on the array thats outputted by data
327
338
data = { ! comparison [ series ] ? [ ] : setXpointsComparison ( ) }
328
339
keys = { keys }
329
340
x = { getCurrentTab }
@@ -333,6 +344,9 @@ const BarGraphComparison = (props) => {
333
344
>
334
345
{ ( barStacks ) =>
335
346
barStacks . map ( ( barStack , idx ) => {
347
+ // Uses map method to iterate through all components,
348
+ // creating a rect component (from visx) for each iteration.
349
+ // height/width/etc. are calculated by visx.
336
350
if ( ! barStack . bars [ currentIndex ] ) {
337
351
return < h1 > No Comparison</ h1 > ;
338
352
}
@@ -405,14 +419,14 @@ const BarGraphComparison = (props) => {
405
419
/>
406
420
< Text
407
421
x = { - xMax / 2 }
408
- y = '15'
409
- transform = ' rotate(-90)'
422
+ y = "15"
423
+ transform = " rotate(-90)"
410
424
fontSize = { 12 }
411
- fill = ' #FFFFFF'
425
+ fill = " #FFFFFF"
412
426
>
413
427
Rendering Time (ms)
414
428
</ Text >
415
- < Text x = { xMax / 2 } y = { yMax + 65 } fontSize = { 12 } fill = ' #FFFFFF' >
429
+ < Text x = { xMax / 2 } y = { yMax + 65 } fontSize = { 12 } fill = " #FFFFFF" >
416
430
Series ID
417
431
</ Text >
418
432
</ svg >
0 commit comments