@@ -9,6 +9,7 @@ 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
import { schemeSet3 } from 'd3-scale-chromatic' ;
12
+ import { makeStyles } from '@material-ui/core/styles' ;
12
13
import Select from '@material-ui/core/Select' ;
13
14
import InputLabel from '@material-ui/core/InputLabel' ;
14
15
import MenuItem from '@material-ui/core/MenuItem' ;
@@ -116,15 +117,70 @@ const BarGraphComparison = (props) => {
116
117
const yMax = height - margin . top - 150 ;
117
118
snapshotIdScale . rangeRound ( [ 0 , xMax ] ) ;
118
119
renderingScale . range ( [ yMax , 0 ] ) ;
119
- const filterSeries = ( comparisonArray ) => {
120
- return comparisonArray . map ( ( sessionName , idx ) => {
121
- return < MenuItem > { sessionName } </ MenuItem > ;
122
- } ) ;
120
+ // const filterSeries = (comparisonArray) => {
121
+ // return comparisonArray.map((sessionName, idx) => {
122
+ // return <MenuItem>{sessionName}</MenuItem>;
123
+ // });
124
+ // };
125
+ // Dropdown to select series.
126
+ const useStyles = makeStyles ( ( theme ) => ( {
127
+ formControl : {
128
+ margin : theme . spacing ( 1 ) ,
129
+ minWidth : 120 ,
130
+ color : 'white' ,
131
+ } ,
132
+ } ) ) ;
133
+
134
+ const classes = useStyles ( ) ;
135
+ const [ series , setSeries ] = React . useState ( 0 ) ;
136
+ const [ open , setOpen ] = React . useState ( false ) ;
137
+
138
+ const handleChange = ( event ) => {
139
+ console . log ( 'Series is : ' , series ) ;
140
+ setSeries ( event . target . value ) ;
141
+ console . log ( 'Series is after click:' , series ) ;
142
+ } ;
143
+
144
+ const handleClose = ( ) => {
145
+ setOpen ( false ) ;
146
+ } ;
147
+
148
+ const handleOpen = ( ) => {
149
+ setOpen ( true ) ;
123
150
} ;
124
- // console.log('getSeriesID', getSeriesId());
151
+
152
+ //this function creates a dropdown selection for each series of snapshots saved
153
+ // const filterSeries = (comparisonArray) => {
154
+ // return comparisonArray.map((sessionName, idx) => {
155
+ // return <MenuItem>{sessionName}</MenuItem>;
156
+ // });
157
+ // };
158
+
125
159
return (
126
160
< div >
127
161
< h1 > { `Current Snapshot: ${ currentIndex + 1 } ` } </ h1 >
162
+ < FormControl className = { classes . formControl } >
163
+ < InputLabel id = "demo-controlled-open-select-label" >
164
+ Select Series
165
+ </ InputLabel >
166
+ < Select
167
+ labelId = "demo-controlled-open-select-label whi"
168
+ id = "demo-controlled-open-select"
169
+ open = { open }
170
+ onClose = { handleClose }
171
+ onOpen = { handleOpen }
172
+ value = { series }
173
+ onChange = { handleChange }
174
+ >
175
+ { comparison . map ( ( tabElem , index ) => {
176
+ return (
177
+ < MenuItem value = { index } >
178
+ { `Series ${ tabElem . currentTab } ` }
179
+ </ MenuItem >
180
+ ) ;
181
+ } ) }
182
+ </ Select >
183
+ </ FormControl >
128
184
< svg ref = { containerRef } width = { width } height = { height } >
129
185
{ }
130
186
< rect
@@ -200,7 +256,7 @@ const BarGraphComparison = (props) => {
200
256
</ BarStack >
201
257
< BarStack
202
258
// Comparison Barstack
203
- data = { ! comparison ? [ ] : comparison [ 0 ] . data . barStack }
259
+ data = { ! comparison ? [ ] : comparison [ series ] . data . barStack }
204
260
// data={data.barStack}
205
261
keys = { keys }
206
262
// x={getSnapshotId}
@@ -211,7 +267,10 @@ const BarGraphComparison = (props) => {
211
267
>
212
268
{ ( barStacks ) =>
213
269
barStacks . map ( ( barStack , idx ) => {
214
- if ( barStacks . length === 0 ) return < h1 > No Comparison</ h1 > ;
270
+ if ( ! barStack . bars [ currentIndex ] ) {
271
+ return < h1 > No Comparison</ h1 > ;
272
+ }
273
+ console . log ( 'barStacks in Comparison' , barStacks ) ;
215
274
const bar = barStack . bars [ currentIndex ] ;
216
275
return (
217
276
< rect
0 commit comments