Skip to content

Commit 750d4b9

Browse files
authored
Merge pull request #10 from oslabs-beta/peng
fix the bug where the default snapshot in the graph is not correct
2 parents 56a42b0 + cdb7559 commit 750d4b9

File tree

8 files changed

+23
-20
lines changed

8 files changed

+23
-20
lines changed

src/app/components/BarGraph.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const tooltipStyles = {
6262

6363
const BarGraph = props => {
6464
const [{ tabs, currentTab }, dispatch] = useStoreContext();
65-
const { width, height, data, comparison, setRoute, allRoutes, filteredSnapshots, setSnapshot} = props;
65+
const { width, height, data, comparison, setRoute, allRoutes, filteredSnapshots, snapshot, setSnapshot} = props;
6666
const [ seriesNameInput, setSeriesNameInput ] = useState(`Series ${comparison.length + 1}`);
6767
const {
6868
tooltipOpen,
@@ -94,13 +94,11 @@ const BarGraph = props => {
9494
// }
9595
const rgb = ["rgba(50, 100, 241, .5)", "rgba(90, 150, 217, .5)", "rgba(200, 30, 7, .5)", "rgba(23, 233, 217, .5)", "rgba(150, 227, 19, .5)"]
9696
for (const [key, value] of Object.entries(data.barStack[0])) {
97-
// console.log(i);
9897
console.log(xMax, '<-- xmax');
9998
if (key !== 'snapshotId' && key !== 'route'){
100-
console.log(`${key}: ${value}`);
99+
//console.log(`${key}: ${value}`);
101100
// let color = colorGen();
102101
if (i === 0) {
103-
console.log('i = 0');
104102
BarArray.push(<Bar
105103
min={'outer min'}
106104
max={'first if'}
@@ -268,6 +266,7 @@ const BarGraph = props => {
268266
}
269267
dispatch(save(toStorage));
270268
};
269+
console.log(data.barStack, 'data.barStack before graph');
271270

272271
// FTRI9 note - need to ensure text box is not empty before saving
273272
const textbox = tabs[currentTab].seriesSavedStatus === 'inputBoxOpen' ? <input type="text" id="seriesname" placeholder="Enter Series Name" onChange={e => setSeriesNameInput(e.target.value)} /> : null;
@@ -288,8 +287,10 @@ const BarGraph = props => {
288287
labelId="demo-simple-select-label"
289288
id="routes-select"
290289
onChange={e => {
291-
setSnapshot('All Snapshots');
292290
setRoute(e.target.value);
291+
setSnapshot('All Snapshots');
292+
const defaultSnapShot = document.querySelector('#snapshot-select');
293+
defaultSnapShot.value = 'defaultSnapShot';
293294
}}
294295
>
295296
<option>
@@ -306,10 +307,10 @@ const BarGraph = props => {
306307
<label id="routes-dropdown">Select Snapshot: </label>
307308
<select
308309
labelId="demo-simple-select-label"
309-
id="routes-select"
310-
onChange={e => setSnapshot(e.target.value)}
310+
id="snapshot-select"
311+
onChange={e => setSnapshot(e.target.value)}
311312
>
312-
<option>
313+
<option value="defaultSnapShot">
313314
All Snapshots
314315
</option>
315316
{filteredSnapshots.map(route => (
@@ -329,7 +330,7 @@ const BarGraph = props => {
329330
fill={background}
330331
rx={14}
331332
/>
332-
{data.barStack.length > 1 ? (
333+
{snapshot === 'All Snapshots' ? (
333334
<><Grid
334335
top={margin.top}
335336
left={margin.left}
@@ -499,9 +500,7 @@ const BarGraph = props => {
499500
Snapshot ID
500501
</Text>
501502
</>
502-
)
503-
}
504-
503+
)}
505504

506505
</svg>
507506
{/* FOR HOVER OVER DISPLAY */}

src/app/components/ComponentMap.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,13 @@ export default function ComponentMap({
217217

218218
// find the node that has been selected and use it as the root
219219
const startNode = null;
220+
let rootNode;
220221
const findSelectedNode = () => {
221222
for (const node of nodeList) {
222-
if (node.name === selectedNode) {
223-
startNode = node;
224-
}
223+
if (node.name === 'root') rootNode = node;
224+
if (node.name === selectedNode) startNode = node;
225225
}
226+
if (startNode === null) startNode = rootNode;
226227
};
227228
findSelectedNode();
228229

src/app/components/LinkControls.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const collectNodes = (node) => {
4747
}
4848
}
4949
}
50-
}
50+
};
5151

5252
export default function LinkControls({
5353
layout,
@@ -113,7 +113,7 @@ export default function LinkControls({
113113
<label> Select:</label>
114114
&nbsp; {/*This is a non-breaking space - Prevents an automatic line break at this position */}
115115
<input id='selectInput' list='nodeOptions' type='text' name="nodeOptions"
116-
onChange={e => { setSelectedNode(e.target.value) }}
116+
onChange={e => setSelectedNode(e.target.value)}
117117
style={dropDownStyle}
118118
/>
119119
<datalist id='nodeOptions'>

src/app/components/PerformanceVisx.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ const PerformanceVisx = (props: BarStackProps) => {
303303
allRoutes={allRoutes}
304304
filteredSnapshots={filteredSnapshots}
305305
setSnapshot={setSnapshot}
306+
snapshot={snapshot}
306307
/>
307308
</div>
308309
);

src/app/constants/actionTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ export const SAVE = 'SAVE';
2323
export const DELETE_SERIES = 'DELETE_SERIES';
2424
export const SET_CURRENT_LOCATION = 'SET_CURRENT_LOCATION';
2525
export const SET_CURRENT_TAB_IN_APP = 'SET_CURRENT_TAB_IN_APP';
26-
export const TUTORIAL_SAVE_SERIES_TOGGLE = 'TUTORIAL_SAVE_SERIES_TOGGLE';
26+
export const TUTORIAL_SAVE_SERIES_TOGGLE = 'TUTORIAL_SAVE_SERIES_TOGGLE';

src/app/reducers/mainReducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default (state, action) => produce(state, draft => {
3434
}
3535
}
3636
};
37-
37+
3838
switch (action.type) {
3939
// This saves the series user wants to save to chrome local storage
4040
case types.SAVE: {

src/app/styles/components/_performanceVisx.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
text-align: left;
3838
}
3939

40-
#routes-select {
40+
#routes-select, #snapshot-select{
4141
color: white !important;
4242
background-color: #ff6569 !important;
4343
font: 400 14px 'Roboto', sans-serif;
@@ -48,6 +48,7 @@
4848
text-align: center;
4949
}
5050

51+
5152
#seriesname {
5253
float: right;
5354
width: 220px;

src/backend/linkFiber.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import AtomsRelationship from '../app/components/AtomsRelationship';
3838
declare global {
3939
interface Window {
4040
__REACT_DEVTOOLS_GLOBAL_HOOK__?: any;
41+
__REDUX_DEVTOOLS_EXTENSION__?: any;
4142
}
4243
}
4344
let fiberRoot = null;

0 commit comments

Comments
 (0)