@@ -19,6 +19,7 @@ import FormHelperText from '@material-ui/core/FormHelperText';
19
19
import snapshots from './snapshots' ;
20
20
import { onHover , onHoverExit } from '../actions/actions' ;
21
21
import { useStoreContext } from '../store' ;
22
+ import { save } from '../actions/actions' ;
22
23
/* TYPESCRIPT */
23
24
interface data {
24
25
snapshotId ?: string ;
@@ -71,31 +72,18 @@ const tooltipStyles = {
71
72
const BarGraphComparison = ( props ) => {
72
73
const [ { tabs, currentTab } , dispatch ] = useStoreContext ( ) ;
73
74
const { width, height, data, comparison } = props ;
74
-
75
75
const [ series , setSeries ] = React . useState ( 0 ) ;
76
76
const [ open , setOpen ] = React . useState ( false ) ;
77
77
const [ maxRender , setMaxRender ] = React . useState ( data . maxTotalRender ) ;
78
78
79
- // console.log('comparison >>>', comparison);
80
- // console.log('tabs[currentTab] >>>', tabs[currentTab]);
81
- // console.log('props in comparison graph >>>', props);
82
- // console.log('data >>>>>', data);
83
- // change scale of graph based on clicking of forward and backwards buttons effect
84
- // useEffect(() => {
85
- // console.log('setSeries is changing everytime currentIndex changes');
86
- // //change the state with setChangeSeries
87
- // setSeries(tabs[currentTab].sliderIndex);
88
- // }, [tabs[currentTab].sliderIndex]);
89
-
90
- // console.log('tabs in Bargraphs comparison >>', tabs);
91
79
function titleFilter ( comparisonArray ) {
92
80
return comparisonArray . filter (
93
81
( elem ) => elem . title === tabs [ currentTab ] . title
94
82
) ;
95
83
}
96
- // console.log('tabs in BGComp >>>', tabs);
84
+
97
85
const currentIndex = tabs [ currentTab ] . sliderIndex ;
98
- // console.log('sliderIndx outside of bargraph >>>', currentIndex);
86
+
99
87
const {
100
88
tooltipOpen,
101
89
tooltipLeft,
@@ -116,16 +104,15 @@ const BarGraphComparison = (props) => {
116
104
const formatRenderTime = ( time ) => `${ time } ms ` ;
117
105
118
106
// create visualization SCALES with cleaned data
107
+ //the domain array elements will place the bars along the x-axis
119
108
const snapshotIdScale = scaleBand < string > ( {
120
- // domain: getSnapshotId(data.barStack[currentIndex]),
121
- // domain: [currentTab, comparison[series].currentTab],
122
109
domain : [
123
110
`Current Tab Series` ,
124
111
`Series ${ ! comparison [ series ] ? null : series + 1 } ` ,
125
112
] ,
126
113
padding : 0.2 ,
127
114
} ) ;
128
-
115
+ // calculateMax
129
116
const calculateMaxTotalRender = ( series ) => {
130
117
const currentSeriesBarStacks = ! comparison [ series ]
131
118
? [ ]
@@ -150,28 +137,23 @@ const BarGraphComparison = (props) => {
150
137
range : schemeSet3 ,
151
138
} ) ;
152
139
153
- // console.log('rendering scale invocation', renderingScale);
154
140
// setting max dimensions and scale ranges
155
141
const xMax = width - margin . left - margin . right ;
156
- const yMax = height - margin . top - 150 ;
142
+ const yMax = height - margin . top - 200 ;
157
143
snapshotIdScale . rangeRound ( [ 0 , xMax ] ) ;
158
144
renderingScale . range ( [ yMax , 0 ] ) ;
159
145
160
- // const filterSeries = (comparisonArray) => {
161
- // return comparisonArray.map((sessionName, idx) => {
162
- // return <MenuItem>{sessionName}</MenuItem>;
163
- // });
164
- // };
165
146
// Dropdown to select series.
166
147
const useStyles = makeStyles ( ( theme ) => ( {
167
148
formControl : {
168
149
margin : theme . spacing ( 1 ) ,
169
150
minWidth : 80 ,
170
- // padding: '0.5rem',
171
151
height : 30 ,
172
152
} ,
173
153
select : {
174
154
minWidth : 80 ,
155
+ fontSize : '.75rem' ,
156
+ fontWeight : '200' ,
175
157
border : '1px solid grey' ,
176
158
borderRadius : 4 ,
177
159
color : 'grey' ,
@@ -183,9 +165,6 @@ const BarGraphComparison = (props) => {
183
165
184
166
const handleChange = ( event ) => {
185
167
setSeries ( event . target . value ) ;
186
- // console.log('handleCh renderTime', renderTime);
187
- // // setMaxRender(renderTime);
188
- // console.log('maxRender', maxRender);
189
168
} ;
190
169
191
170
const handleClose = ( ) => {
@@ -196,34 +175,20 @@ const BarGraphComparison = (props) => {
196
175
setOpen ( true ) ;
197
176
} ;
198
177
199
- //this function creates a dropdown selection for each series of snapshots saved
200
- // const filterSeries = (comparisonArray) => {
201
- // return comparisonArray.map((sessionName, idx) => {
202
- // return <MenuItem>{sessionName}</MenuItem>;
203
- // });
204
- // };
178
+ const toStorage = {
179
+ currentTab,
180
+ title : tabs [ currentTab ] [ 'title' ] ,
181
+ data,
182
+ } ;
205
183
206
184
return (
207
185
< div >
208
- { /* <h1>{`Current Snapshot: ${currentIndex + 1}`}</h1> */ }
209
- { /* <div class="dropdown dropdown-dark">
210
- <select name="two" class="dropdown-select">
211
- {!comparison[series] ? (
212
- <option value={series}>No series available</option>
213
- ) : (
214
- titleFilter(comparison).map((tabElem, index) => {
215
- return <option value={index}>{`Series ${index + 1}`}</option>;
216
- })
217
- )}
218
- </select>
219
- </div> */ }
220
186
< div className = "series-options-container" >
221
- < div className = "snapshotId-container" >
222
- < h1 className = "snashotId-header" >
223
- { ' ' }
224
- Snapshot ID: { currentIndex + 1 } { ' ' }
225
- </ h1 >
187
+ < div className = "snapshotId-header" >
188
+ { ' ' }
189
+ Snapshot ID: { currentIndex + 1 } { ' ' }
226
190
</ div >
191
+
227
192
< div className = "dropdown-and-save-series-container" >
228
193
< FormControl variant = "outlined" className = { classes . formControl } >
229
194
< Select
@@ -235,8 +200,6 @@ const BarGraphComparison = (props) => {
235
200
onClose = { handleClose }
236
201
onOpen = { handleOpen }
237
202
value = { series }
238
- //data={data.barStack}
239
- // value={titleFilter(comparison)}
240
203
onChange = { handleChange }
241
204
>
242
205
{ ! comparison [ series ] ? (
@@ -250,8 +213,16 @@ const BarGraphComparison = (props) => {
250
213
) }
251
214
</ Select >
252
215
</ FormControl >
216
+
217
+ < button
218
+ className = "save-series-button"
219
+ onClick = { ( ) => dispatch ( save ( toStorage ) ) }
220
+ >
221
+ Save Series
222
+ </ button >
253
223
</ div >
254
224
</ div >
225
+
255
226
< svg ref = { containerRef } width = { width } height = { height } >
256
227
{ }
257
228
< rect
@@ -276,27 +247,21 @@ const BarGraphComparison = (props) => {
276
247
< Group top = { margin . top } left = { margin . left } >
277
248
< BarStack
278
249
// OG Barstack
279
- // data={!comparison ? [] : comparison}
280
250
data = { data . barStack }
281
251
keys = { keys }
282
- // x={getSnapshotId}
283
252
x = { getSnapshotId }
284
253
xScale = { snapshotIdScale }
285
254
yScale = { renderingScale }
286
255
color = { colorScale }
287
256
>
288
257
{ ( barStacks ) =>
289
258
barStacks . map ( ( barStack , idx ) => {
290
- console . log ( 'maxTotalRender 1st Barstack' , data . maxTotalRender ) ;
291
259
const bar = barStack . bars [ currentIndex ] ;
292
- // console.log('Y SCALEEE', barStacks);
293
- // console.log('data.barStack >>>', data.barStack);
294
- console . log ( 'OG bar.x' , bar . x ) ;
295
260
296
261
return (
297
262
< rect
298
263
key = { `bar-stack-${ idx } -NewView` }
299
- x = { bar . x + 50 }
264
+ x = { bar . x + 30 }
300
265
y = { bar . y }
301
266
height = { bar . height === 0 ? null : bar . height }
302
267
width = { bar . width }
@@ -331,10 +296,8 @@ const BarGraphComparison = (props) => {
331
296
< BarStack
332
297
// Comparison Barstack
333
298
data = { ! comparison [ series ] ? [ ] : comparison [ series ] . data . barStack }
334
- // data={data.barStack}
335
299
keys = { keys }
336
300
x = { getSnapshotId }
337
- // x={getSeriesId}
338
301
xScale = { snapshotIdScale }
339
302
yScale = { renderingScale }
340
303
color = { colorScale }
@@ -344,13 +307,12 @@ const BarGraphComparison = (props) => {
344
307
if ( ! barStack . bars [ currentIndex ] ) {
345
308
return < h1 > No Comparison</ h1 > ;
346
309
}
347
- // console.log('barStacks in Comparison', barStacks);
348
310
const bar = barStack . bars [ currentIndex ] ;
349
- console . log ( 'Comparison bar.x' , bar . x ) ;
311
+
350
312
return (
351
313
< rect
352
314
key = { `bar-stack-${ idx } -${ bar . index } ` }
353
- x = { 275 }
315
+ x = { 225 }
354
316
y = { bar . y }
355
317
height = { bar . height === 0 ? null : bar . height }
356
318
width = { bar . width }
@@ -417,12 +379,10 @@ const BarGraphComparison = (props) => {
417
379
fontSize = { 12 }
418
380
fill = "#FFFFFF"
419
381
>
420
- { ' ' }
421
- Rendering Time (ms){ ' ' }
382
+ Rendering Time (ms)
422
383
</ Text >
423
384
< Text x = { xMax / 2 } y = { yMax + 65 } fontSize = { 12 } fill = "#FFFFFF" >
424
- { ' ' }
425
- Series ID{ ' ' }
385
+ Series ID
426
386
</ Text >
427
387
</ svg >
428
388
{ /* FOR HOVER OVER DISPLAY */ }
0 commit comments