@@ -70,21 +70,11 @@ const tooltipStyles = {
70
70
const BarGraphComparison = props => {
71
71
const [ { tabs, currentTab } , dispatch ] = useStoreContext ( ) ;
72
72
const {
73
- width, height, data, comparison,
73
+ width, height, data, comparison, setSeries , series , setAction
74
74
} = props ;
75
- const [ series , setSeries ] = React . useState ( 0 ) ;
76
75
const [ snapshots , setSnapshots ] = React . useState ( 0 ) ;
77
76
const [ open , setOpen ] = React . useState ( false ) ;
78
77
const [ picOpen , setPicOpen ] = React . useState ( false ) ;
79
- const [ maxRender , setMaxRender ] = React . useState ( data . maxTotalRender ) ;
80
-
81
- function titleFilter ( comparisonArray ) {
82
- // const comparisonArrayModded = comparisonArray[0];
83
- console . log ( 'titleFilter' , comparisonArray ) ;
84
- return comparisonArray . filter (
85
- elem => elem . title . split ( '-' ) [ 1 ] === tabs [ currentTab ] . title . split ( '-' ) [ 1 ] ,
86
- ) ;
87
- }
88
78
89
79
const currentIndex = tabs [ currentTab ] . sliderIndex ;
90
80
@@ -121,9 +111,6 @@ const BarGraphComparison = props => {
121
111
// with the render time of the current tab.
122
112
// The max render time will determine the Y-axis's highest number.
123
113
const calculateMaxTotalRender = series => {
124
- console . log ( comparison )
125
- console . log ( series )
126
- // let currentMax = 5
127
114
const currentSeriesBarStacks = ! comparison [ series ]
128
115
? [ ]
129
116
: comparison [ series ] . data . barStack ;
@@ -175,45 +162,37 @@ const BarGraphComparison = props => {
175
162
176
163
const classes = useStyles ( ) ;
177
164
178
- const handleChange = event => {
165
+ const handleSeriesChange = event => {
179
166
setSeries ( event . target . value ) ;
180
- // setXpoints( );
167
+ setAction ( false ) ;
181
168
} ;
182
169
183
170
const handleClose = ( ) => {
184
171
setOpen ( false ) ;
185
- // setXpoints();
186
172
} ;
187
173
188
174
const handleOpen = ( ) => {
189
175
setOpen ( true ) ;
190
- // setXpoints();
191
176
} ;
192
177
193
- const picHandleChange = event => {
194
- setSnapshots ( ` ${ ( event . target . value + 1 ) . toString ( ) } .0` ) ;
195
- // setXpoints( );
178
+ const handleActionChange = event => {
179
+ setAction ( event . target . value ) ;
180
+ setSeries ( false ) ;
196
181
} ;
197
182
198
183
const picHandleClose = ( ) => {
199
184
setPicOpen ( false ) ;
200
- // setXpoints();
201
185
} ;
202
186
203
187
const picHandleOpen = ( ) => {
204
188
setPicOpen ( true ) ;
205
- // setXpoints();
206
189
} ;
207
190
208
191
// manually assignin X -axis points with tab ID.
209
192
function setXpointsComparison ( ) {
210
193
comparison [ series ] . data . barStack . forEach ( elem => {
211
194
elem . currentTab = 'comparison' ;
212
195
} ) ;
213
- // comparison[series].data.barStack.currentTab = currentTab;
214
- console . log ( comparison )
215
- console . log ( series )
216
- console . log ( comparison [ series ] . data . barStack )
217
196
return comparison [ series ] . data . barStack ;
218
197
}
219
198
function setXpointsCurrentTab ( ) {
@@ -235,6 +214,15 @@ const BarGraphComparison = props => {
235
214
for ( let i = 0 ; i < classname . length ; i ++ ) {
236
215
classname [ i ] . addEventListener ( 'click' , animateButton , false ) ;
237
216
}
217
+ const seriesList = comparison . map ( elem => elem . data . barStack ) ;
218
+ const actionsList = seriesList . flat ( ) ;
219
+ const testList = actionsList . map ( elem => elem . name ) ;
220
+
221
+ const finalList = [ ] ;
222
+ for ( let i = 0 ; i < testList . length ; i ++ ) {
223
+ if ( testList [ i ] !== "" && ! finalList . includes ( testList [ i ] ) ) finalList . push ( testList [ i ] ) ;
224
+ }
225
+
238
226
return (
239
227
< div >
240
228
< div className = "series-options-container" >
@@ -248,7 +236,7 @@ const BarGraphComparison = props => {
248
236
>
249
237
Clear All Series
250
238
</ button >
251
- < h4 style = { { padding : '0 1rem' } } > Comparison Series: </ h4 >
239
+ < h4 style = { { padding : '0 1rem' } } > Compare Series: </ h4 >
252
240
< FormControl variant = "outlined" className = { classes . formControl } >
253
241
< Select
254
242
style = { { color : 'white' } }
@@ -259,21 +247,18 @@ const BarGraphComparison = props => {
259
247
onClose = { handleClose }
260
248
onOpen = { handleOpen }
261
249
value = { series }
262
- onChange = { handleChange }
250
+ onChange = { handleSeriesChange }
263
251
>
264
- { ! comparison [ series ] ? (
252
+ { ! comparison . length ? (
265
253
< MenuItem > No series available</ MenuItem >
266
254
) : (
267
- // titleFilter(comparison).map((tabElem, index) => (
268
- // <MenuItem value={index}>{`Series ${index + 1}`}</MenuItem>
269
- // ))
270
255
comparison . map ( ( tabElem , index ) => (
271
- < MenuItem value = { index } > { tabElem . name } </ MenuItem >
256
+ < MenuItem key = { `MenuItem ${ tabElem . name } ` } value = { index } > { tabElem . name } </ MenuItem >
272
257
) )
273
258
) }
274
259
</ Select >
275
260
</ FormControl >
276
- { /* <h4 style={{ padding: '0 1rem' }}>Comparator Snapshot? </h4>
261
+ < h4 style = { { padding : '0 1rem' } } > Compare Actions </ h4 >
277
262
< FormControl variant = "outlined" className = { classes . formControl } >
278
263
< Select
279
264
style = { { color : 'white' } }
@@ -283,20 +268,19 @@ const BarGraphComparison = props => {
283
268
open = { picOpen }
284
269
onClose = { picHandleClose }
285
270
onOpen = { picHandleOpen }
286
- value={snapshots } //snapshots
287
- onChange={picHandleChange }
271
+ value = { '' } //snapshots
272
+ onChange = { handleActionChange }
288
273
>
289
274
{ ! comparison [ snapshots ] ? (
290
275
< MenuItem > No snapshots available</ MenuItem >
291
276
) : (
292
- titleFilter(comparison).map((tabElem, index) => {
293
- return (
294
- <MenuItem value={index}>{`${index + 1}` }</MenuItem>
295
- );
296
- })
297
- )}
277
+ finalList . map ( ( elem , index ) => (
278
+ < MenuItem value = { elem } > { elem } </ MenuItem >
279
+ // <MenuItem value="test">{}</MenuItem>
280
+ ) ) )
281
+ }
298
282
</ Select >
299
- </FormControl> */ }
283
+ </ FormControl >
300
284
</ div >
301
285
</ div >
302
286
@@ -335,7 +319,7 @@ const BarGraphComparison = props => {
335
319
// Uses map method to iterate through all components,
336
320
// creating a rect component (from visx) for each iteration.
337
321
// height/width/etc. are calculated by visx.
338
- // to set X and Y scale, it will used the passed in function and
322
+ // to set X and Y scale, it will used the p`assed in function and
339
323
// will run it on the array thats outputted by data
340
324
const bar = barStack . bars [ currentIndex ] ;
341
325
if ( Number . isNaN ( bar . bar [ 1 ] ) || bar . height < 0 ) {
@@ -379,6 +363,8 @@ const BarGraphComparison = props => {
379
363
// Comparison Barstack (populates based on series selected)
380
364
// to set X and Y scale, it will used the passed in function and
381
365
// will run it on the array thats outputted by data
366
+ // setXpointsComparison() }
367
+ // comparison[series].data.barStack
382
368
data = { ! comparison [ series ] ? [ ] : setXpointsComparison ( ) }
383
369
keys = { keys }
384
370
x = { getCurrentTab }
0 commit comments