@@ -8,6 +8,7 @@ import { AxisBottom, AxisLeft } from '@visx/axis';
8
8
import { scaleBand , scaleLinear , scaleOrdinal } from '@visx/scale' ;
9
9
import { useTooltip , useTooltipInPortal , defaultStyles } from '@visx/tooltip' ;
10
10
import { Text } from '@visx/text' ;
11
+
11
12
import { schemeSet3 } from 'd3-scale-chromatic' ;
12
13
import { makeStyles } from '@material-ui/core/styles' ;
13
14
import Select from '@material-ui/core/Select' ;
@@ -18,7 +19,6 @@ import FormHelperText from '@material-ui/core/FormHelperText';
18
19
import snapshots from './snapshots' ;
19
20
import { onHover , onHoverExit } from '../actions/actions' ;
20
21
import { useStoreContext } from '../store' ;
21
-
22
22
/* TYPESCRIPT */
23
23
interface data {
24
24
snapshotId ?: string ;
@@ -112,7 +112,6 @@ const BarGraphComparison = (props) => {
112
112
113
113
// data accessor (used to generate scales) and formatter (add units for on hover box)
114
114
const getSnapshotId = ( d : snapshot ) => d . snapshotId ;
115
- // const getSeriesId = (d: series) => d.currentTab;
116
115
const formatSnapshotId = ( id ) => `Snapshot ID: ${ id } ` ;
117
116
const formatRenderTime = ( time ) => `${ time } ms ` ;
118
117
@@ -121,8 +120,8 @@ const BarGraphComparison = (props) => {
121
120
// domain: getSnapshotId(data.barStack[currentIndex]),
122
121
// domain: [currentTab, comparison[series].currentTab],
123
122
domain : [
124
- `Series ${ ! currentTab ? null : currentTab } ( Current Tab) ` ,
125
- `Series ${ ! comparison [ series ] ? null : comparison [ series ] . currentTab } ` ,
123
+ `Current Tab Series ` ,
124
+ `Series ${ ! comparison [ series ] ? null : series + 1 } ` ,
126
125
] ,
127
126
padding : 0.2 ,
128
127
} ) ;
@@ -131,16 +130,14 @@ const BarGraphComparison = (props) => {
131
130
const currentSeriesBarStacks = ! comparison [ series ]
132
131
? [ ]
133
132
: comparison [ series ] . data . barStack ;
134
- console . log (
135
- 'currentSeriesBarStacks index in Max func' ,
136
- currentSeriesBarStacks [ series ]
137
- ) ;
138
- let renderTimes = Object . values ( currentSeriesBarStacks [ series ] ) ;
139
- renderTimes = renderTimes . slice ( 1 ) ;
140
- // console.log('RendERrrrTimes', renderTimes);
141
- const renderTotal = renderTimes . reduce ( ( a , b ) => a + b ) ;
142
- // console.log('renderTotal', renderTotal);
143
- return renderTotal ;
133
+ if ( currentSeriesBarStacks . length === 0 ) return 0 ;
134
+ let currentMax = - Infinity ;
135
+ for ( let i = 0 ; i < currentSeriesBarStacks . length ; i += 1 ) {
136
+ const renderTimes = Object . values ( currentSeriesBarStacks [ i ] ) . slice ( 1 ) ;
137
+ const renderTotal = renderTimes . reduce ( ( acc , curr ) => acc + curr ) ;
138
+ if ( renderTotal > currentMax ) currentMax = renderTotal ;
139
+ }
140
+ return currentMax ;
144
141
} ;
145
142
146
143
const renderingScale = scaleLinear < number > ( {
@@ -169,21 +166,26 @@ const BarGraphComparison = (props) => {
169
166
const useStyles = makeStyles ( ( theme ) => ( {
170
167
formControl : {
171
168
margin : theme . spacing ( 1 ) ,
172
- minWidth : 150 ,
169
+ minWidth : 80 ,
170
+ // padding: '0.5rem',
171
+ height : 30 ,
172
+ } ,
173
+ select : {
174
+ minWidth : 80 ,
173
175
border : '1px solid grey' ,
174
176
borderRadius : 4 ,
175
- borderColor : 'grey' ,
177
+ color : 'grey' ,
178
+ height : 30 ,
176
179
} ,
177
180
} ) ) ;
178
181
179
182
const classes = useStyles ( ) ;
180
183
181
184
const handleChange = ( event ) => {
182
185
setSeries ( event . target . value ) ;
183
- const renderTime = calculateMaxTotalRender ( series ) ;
184
- console . log ( 'handleCh renderTime' , renderTime ) ;
185
- // setMaxRender(renderTime);
186
- console . log ( 'maxRender' , maxRender ) ;
186
+ // console.log('handleCh renderTime', renderTime);
187
+ // // setMaxRender(renderTime);
188
+ // console.log('maxRender', maxRender);
187
189
} ;
188
190
189
191
const handleClose = ( ) => {
@@ -204,31 +206,52 @@ const BarGraphComparison = (props) => {
204
206
return (
205
207
< div >
206
208
{ /* <h1>{`Current Snapshot: ${currentIndex + 1}`}</h1> */ }
207
- < FormHelperText style = { { color : 'white' } } > Select Series</ FormHelperText >
208
- < FormControl variant = "outlined" className = { classes . formControl } >
209
- < Select
210
- style = { { color : 'white' } }
211
- labelId = "simple-select-outlined-label"
212
- id = "simple-select-outlined"
213
- open = { open }
214
- onClose = { handleClose }
215
- onOpen = { handleOpen }
216
- value = { series }
217
- //data={data.barStack}
218
- // value={titleFilter(comparison)}
219
- onChange = { handleChange }
220
- >
221
- { ! comparison
222
- ? null
223
- : titleFilter ( comparison ) . map ( ( tabElem , index ) => {
224
- return (
225
- < MenuItem value = { index } >
226
- { `Series ${ tabElem . currentTab } ` }
227
- </ MenuItem >
228
- ) ;
229
- } ) }
230
- </ Select >
231
- </ FormControl >
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
+ < div className = "series-options-container" >
221
+ < div className = "snapshotId-container" >
222
+ < h1 className = "snashotId-header" >
223
+ { ' ' }
224
+ Snapshot ID: { currentIndex + 1 } { ' ' }
225
+ </ h1 >
226
+ </ div >
227
+ < div className = "dropdown-and-save-series-container" >
228
+ < FormControl variant = "outlined" className = { classes . formControl } >
229
+ < Select
230
+ style = { { color : 'white' } }
231
+ labelId = "simple-select-outlined-label"
232
+ id = "simple-select-outlined"
233
+ className = { classes . select }
234
+ open = { open }
235
+ onClose = { handleClose }
236
+ onOpen = { handleOpen }
237
+ value = { series }
238
+ //data={data.barStack}
239
+ // value={titleFilter(comparison)}
240
+ onChange = { handleChange }
241
+ >
242
+ { ! comparison [ series ] ? (
243
+ < MenuItem > No series available</ MenuItem >
244
+ ) : (
245
+ titleFilter ( comparison ) . map ( ( tabElem , index ) => {
246
+ return (
247
+ < MenuItem value = { index } > { `Series ${ index + 1 } ` } </ MenuItem >
248
+ ) ;
249
+ } )
250
+ ) }
251
+ </ Select >
252
+ </ FormControl >
253
+ </ div >
254
+ </ div >
232
255
< svg ref = { containerRef } width = { width } height = { height } >
233
256
{ }
234
257
< rect
@@ -268,6 +291,7 @@ const BarGraphComparison = (props) => {
268
291
const bar = barStack . bars [ currentIndex ] ;
269
292
// console.log('Y SCALEEE', barStacks);
270
293
// console.log('data.barStack >>>', data.barStack);
294
+ console . log ( 'OG bar.x' , bar . x ) ;
271
295
272
296
return (
273
297
< rect
@@ -322,10 +346,11 @@ const BarGraphComparison = (props) => {
322
346
}
323
347
// console.log('barStacks in Comparison', barStacks);
324
348
const bar = barStack . bars [ currentIndex ] ;
349
+ console . log ( 'Comparison bar.x' , bar . x ) ;
325
350
return (
326
351
< rect
327
352
key = { `bar-stack-${ idx } -${ bar . index } ` }
328
- x = { 300 }
353
+ x = { 275 }
329
354
y = { bar . y }
330
355
height = { bar . height === 0 ? null : bar . height }
331
356
width = { bar . width }
0 commit comments