Skip to content

Commit 2331a42

Browse files
author
Kevin Ngo
committed
Add dropdown menu to select series from Chrome storage
1 parent cf32b91 commit 2331a42

File tree

1 file changed

+66
-7
lines changed

1 file changed

+66
-7
lines changed

src/app/components/BarGraphComparison.tsx

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { scaleBand, scaleLinear, scaleOrdinal } from '@visx/scale';
99
import { useTooltip, useTooltipInPortal, defaultStyles } from '@visx/tooltip';
1010
import { Text } from '@visx/text';
1111
import { schemeSet3 } from 'd3-scale-chromatic';
12+
import { makeStyles } from '@material-ui/core/styles';
1213
import Select from '@material-ui/core/Select';
1314
import InputLabel from '@material-ui/core/InputLabel';
1415
import MenuItem from '@material-ui/core/MenuItem';
@@ -116,15 +117,70 @@ const BarGraphComparison = (props) => {
116117
const yMax = height - margin.top - 150;
117118
snapshotIdScale.rangeRound([0, xMax]);
118119
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);
123150
};
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+
125159
return (
126160
<div>
127161
<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>
128184
<svg ref={containerRef} width={width} height={height}>
129185
{}
130186
<rect
@@ -200,7 +256,7 @@ const BarGraphComparison = (props) => {
200256
</BarStack>
201257
<BarStack
202258
// Comparison Barstack
203-
data={!comparison ? [] : comparison[0].data.barStack}
259+
data={!comparison ? [] : comparison[series].data.barStack}
204260
// data={data.barStack}
205261
keys={keys}
206262
// x={getSnapshotId}
@@ -211,7 +267,10 @@ const BarGraphComparison = (props) => {
211267
>
212268
{(barStacks) =>
213269
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);
215274
const bar = barStack.bars[currentIndex];
216275
return (
217276
<rect

0 commit comments

Comments
 (0)