Skip to content

Commit de5fbb5

Browse files
authored
Merge pull request #5 from oslabs-beta/DBBRanch
early edits to comparison screen
2 parents 5cf46af + a334831 commit de5fbb5

File tree

2 files changed

+52
-8
lines changed

2 files changed

+52
-8
lines changed

src/app/components/BarGraphComparison.tsx

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,14 @@ const BarGraphComparison = (props) => {
7070
const [{ tabs, currentTab }, dispatch] = useStoreContext();
7171
const { width, height, data, comparison } = props;
7272
const [series, setSeries] = React.useState(0);
73+
const [snapshots, setSnapshots] = React.useState(0);
7374
const [open, setOpen] = React.useState(false);
75+
const [picOpen, setPicOpen] = React.useState(false);
7476
const [maxRender, setMaxRender] = React.useState(data.maxTotalRender);
77+
console.log('comparison:', comparison)
78+
console.log('tabs:', tabs)
7579

7680
function titleFilter(comparisonArray) {
77-
console.log("titleFilter comparison array", comparisonArray)
7881
return comparisonArray.filter(
7982
(elem) => elem.title.split('-')[1] === tabs[currentTab].title.split('-')[1]
8083
);
@@ -93,6 +96,7 @@ const BarGraphComparison = (props) => {
9396
let tooltipTimeout: number;
9497

9598
const { containerRef, TooltipInPortal } = useTooltipInPortal();
99+
console.log("containerRef", containerRef)
96100

97101
const keys = Object.keys(data.componentData);
98102

@@ -101,6 +105,8 @@ const BarGraphComparison = (props) => {
101105
const formatSnapshotId = (id) => `Snapshot ID: ${id}`;
102106
const formatRenderTime = (time) => `${time} ms `;
103107
const getCurrentTab = (storedSeries) => storedSeries.currentTab;
108+
109+
104110
// create visualization SCALES with cleaned data
105111
// the domain array/xAxisPoints elements will place the bars along the x-axis
106112
const xAxisPoints = ['currentTab', 'comparison'];
@@ -184,18 +190,36 @@ const BarGraphComparison = (props) => {
184190
// setXpoints();
185191
};
186192

193+
const picHandleChange = (event) => {
194+
console.log('setsnapshot to', (event.target.value+1).toString() + ".0")
195+
setSnapshots((event.target.value+1).toString() + ".0");
196+
// setXpoints();
197+
};
198+
199+
const picHandleClose = () => {
200+
setPicOpen(false);
201+
// setXpoints();
202+
};
203+
204+
const picHandleOpen = () => {
205+
setPicOpen(true);
206+
// setXpoints();
207+
};
208+
187209
//manually assignin X -axis points with tab ID.
188210
function setXpointsComparison() {
189211
comparison[series].data.barStack.forEach((elem) => {
190212
elem.currentTab = 'comparison';
191213
});
192214
//comparison[series].data.barStack.currentTab = currentTab;
215+
console.log("setXpointsComparison/comparison[series].data.barStack:", comparison[series].data.barStack)
193216
return comparison[series].data.barStack;
194217
}
195218
function setXpointsCurrentTab() {
196219
data.barStack.forEach((element) => {
197220
element.currentTab = 'currentTab';
198221
});
222+
console.log("setXpointsCurrentTan/data.barStack:", data.barStack)
199223
return data.barStack;
200224
}
201225
const animateButton = function (e) {
@@ -214,10 +238,7 @@ const BarGraphComparison = (props) => {
214238
return (
215239
<div>
216240
<div className="series-options-container">
217-
<div className="snapshotId-header">
218-
{' '}
219-
Snapshot ID: {currentIndex + 1}{' '}
220-
</div>
241+
221242

222243
<div className="dropdown-and-delete-series-container">
223244
<button
@@ -228,7 +249,7 @@ const BarGraphComparison = (props) => {
228249
>
229250
Clear All Series
230251
</button>
231-
<h4 style={{ padding: '0 1rem' }}>Compare with: </h4>
252+
<h4 style={{ padding: '0 1rem' }}>Comparison Series: </h4>
232253
<FormControl variant="outlined" className={classes.formControl}>
233254
<Select
234255
style={{ color: 'white' }}
@@ -246,7 +267,31 @@ const BarGraphComparison = (props) => {
246267
) : (
247268
titleFilter(comparison).map((tabElem, index) => {
248269
return (
249-
<MenuItem value={index}>{`Series ${index + 1}`}</MenuItem>
270+
<MenuItem value={index}>{`${currentTab} ${index + 1}`}</MenuItem>
271+
);
272+
})
273+
)}
274+
</Select>
275+
</FormControl>
276+
<h4 style={{ padding: '0 1rem' }}>Comparator Snapshot? </h4>
277+
<FormControl variant="outlined" className={classes.formControl}>
278+
<Select
279+
style={{ color: 'white' }}
280+
labelId="snapshot-select"
281+
id="snapshot-select"
282+
className={classes.select}
283+
open={picOpen}
284+
onClose={picHandleClose}
285+
onOpen={picHandleOpen}
286+
value={snapshots} //snapshots
287+
onChange={picHandleChange}
288+
>
289+
{!comparison[snapshots] ? (
290+
<MenuItem>No snapshots available</MenuItem>
291+
) : (
292+
titleFilter(comparison).map((tabElem, index) => {
293+
return (
294+
<MenuItem value={index}>{`${index + 1}`}</MenuItem>
250295
);
251296
})
252297
)}

src/app/containers/MainContainer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const mixpanel = require('mixpanel').init('12fa2800ccbf44a5c36c37bc9776e4c0', {
2020

2121
function MainContainer(): any {
2222
const [store, dispatch] = useStoreContext();
23-
console.log("storecont:", useStoreContext());
2423
const { tabs, currentTab, port: currentPort } = store;
2524
const [actionView, setActionView] = useState(true);
2625
//this function handles Time Jump sidebar view

0 commit comments

Comments
 (0)