Skip to content

Commit 39c17e0

Browse files
committed
Finished filter update on performance tab
1 parent 08e07c3 commit 39c17e0

File tree

4 files changed

+73
-82
lines changed

4 files changed

+73
-82
lines changed

src/app/components/BarGraph.tsx

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @ts-nocheck
22
import React, { useEffect, useState } from 'react';
33
import { FormControl, InputLabel, Select, MenuItem } from '@mui/material';
4+
// import Select from 'react-select';
45
import { BarStack } from '@visx/shape';
56
import { SeriesPoint } from '@visx/shape/lib/types';
67
import { Group } from '@visx/group';
@@ -62,7 +63,7 @@ const tooltipStyles = {
6263

6364
const BarGraph = props => {
6465
const [{ tabs, currentTab }, dispatch] = useStoreContext();
65-
const { width, height, data, comparison, setRoute, devRoutes } = props;
66+
const { width, height, data, comparison, setRoute, allRoutes, filteredSnapshots } = props;
6667
const [ seriesNameInput, setSeriesNameInput ] = useState(`Series ${comparison.length + 1}`);
6768
const {
6869
tooltipOpen,
@@ -138,6 +139,13 @@ const BarGraph = props => {
138139
dispatch(save(toStorage));
139140
};
140141

142+
console.log('data-barstack', data.barStack)
143+
144+
// const [isMenuOpen, setIsMenuOpen] = useState(false);
145+
146+
// const onMenuOpen = () => setIsMenuOpen(true);
147+
// const onMenuClose = () => setIsMenuOpen(false);
148+
141149
const textbox = tabs[currentTab].seriesSavedStatus === 'inputBoxOpen' ? <input type="text" id="seriesname" placeholder="Enter Series Name" onChange={e => setSeriesNameInput(e.target.value)} /> : null;
142150
return (
143151
<div className="bargraph-position">
@@ -152,22 +160,27 @@ const BarGraph = props => {
152160
>
153161
Save Series
154162
</button>
155-
<FormControl id="routes-formcontrol">
156-
<InputLabel id="routes-dropdown">Routes</InputLabel>
157-
<Select
158-
labelId="demo-simple-select-label"
159-
id="routes-select"
160-
label="Routes"
161-
onChange={e => setRoute(e.target.value)}
162-
>
163-
{devRoutes.map(route => { return (
164-
<MenuItem value={route} className="routes">
165-
{route}
166-
</MenuItem>
167-
)})}
168-
</Select>
169-
</FormControl>
170163
</div>
164+
{/* <div className="routesContainer"> */}
165+
<FormControl className="routesForm" id="routes-formcontrol" size="small">
166+
<InputLabel id="routes-dropdown">Select Route</InputLabel>
167+
<Select
168+
labelId="demo-simple-select-label"
169+
id="routes-select"
170+
// label="Routes"
171+
onChange={e => setRoute(e.target.value)}
172+
>
173+
<MenuItem value={null}>
174+
All Visited Routes
175+
</MenuItem>
176+
{allRoutes.map(route => (
177+
<MenuItem value={route} className="routes">
178+
{route}
179+
</MenuItem>
180+
))}
181+
</Select>
182+
</FormControl>
183+
{/* </div> */}
171184
<svg ref={containerRef} width={width} height={height}>
172185
<rect
173186
x={0}

src/app/components/PerformanceVisx.tsx

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ const collectNodes = (snaps, componentName) => {
4040
const renderResult = [];
4141
let trackChanges = 0;
4242
let newChange = true;
43-
for (let x = 0; x < snaps.length; x++) {
43+
for (let x = 0; x < snaps.length; x += 1) {
4444
const snapshotList = [];
4545
snapshotList.push(snaps[x]);
46-
for (let i = 0; i < snapshotList.length; i++) {
46+
for (let i = 0; i < snapshotList.length; i += 1) {
4747
const cur = snapshotList[i];
4848
if (cur.name === componentName) {
4949
const renderTime = Number(
@@ -119,7 +119,7 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
119119
}
120120
// increment render frequencies
121121
if (renderTime > 0) {
122-
data.componentData[componentName].renderFrequency++;
122+
data.componentData[componentName].renderFrequency += 1;
123123
}
124124

125125
// add to total render time
@@ -191,7 +191,7 @@ const PerformanceVisx = (props: BarStackProps) => {
191191
const actionsArr = [];
192192

193193
if (seriesArr.length) {
194-
for (let i = 0; i < seriesArr.length; i++) {
194+
for (let i = 0; i < seriesArr.length; i += 1) {
195195
for (const actionObj of seriesArr[i].data.barStack) {
196196
if (actionObj.name === action) {
197197
actionObj.seriesName = seriesArr[i].name;
@@ -230,42 +230,51 @@ const PerformanceVisx = (props: BarStackProps) => {
230230
);
231231
};
232232

233-
// Logic for routeArr - DropDown
234-
// Create an Arr to hold our routes for the dropDown.
235-
const devRoutes: string[] = [];
236-
// Use a for loop to itereate over data and add the prospective routes to our devRoutes arr.
237-
for (let i = 0; i < data.barStack.length; i += 1) {
238-
const url:string = new URL(data.barStack[i].route);
239-
// Making sure devRoutes does not include any additional routes as barStack carries the same Route for every action/state snapshot.
240-
if (!devRoutes.includes(url.pathname)) {
241-
devRoutes.push(url.pathname);
242-
}
243-
}
233+
const allRoutes = [];
234+
const filteredSnapshots = [];
235+
const copyOfBars = [];
244236

245-
const userInputRoutes: string[] = [];
246237
for (let i = 0; i < data.barStack.length; i += 1) {
247-
const url:string = new URL(data.barStack[i].route);
248-
// console.log('route is', route);
249-
// console.log('url.pathname is', url.pathname);
238+
const url = new URL(data.barStack[i].route);
239+
if (!allRoutes.includes(url.pathname)) {
240+
allRoutes.push(url.pathname);
241+
}
250242
if (route && route === url.pathname) {
251-
userInputRoutes.push(data.barStack[i]);
243+
filteredSnapshots.push(data.barStack[i]);
252244
}
253245
}
254246
if (route) {
255-
data.barStack = userInputRoutes;
247+
// copyOfBars = data.barStack;
248+
data.barStack = filteredSnapshots;
256249
}
250+
// console.log('Data', data);
251+
// console.log('URL is ', url);
252+
console.log('data.barStack is ', data.barStack);
253+
console.log('filtered snapshots are ', filteredSnapshots);
254+
// console.log('AllRoutes', allRoutes);
257255

258256
const renderBargraph = () => {
259257
if (hierarchy) {
260258
return (
261259
<div>
262-
<BarGraph data={data} width={width} height={height} comparison={allStorage()} setRoute={setRoute} devRoutes={devRoutes} />
263-
{/* <input type="text" onChange={e => setRoute(e.target.value)} /> */}
260+
<BarGraph
261+
data={data}
262+
width={width}
263+
height={height}
264+
comparison={allStorage()}
265+
setRoute={setRoute}
266+
allRoutes={allRoutes}
267+
copyOfBars={copyOfBars}
268+
filteredSnapshots={filteredSnapshots}
269+
/>
264270
</div>
265271
);
266272
}
267273
};
268274

275+
console.log('data', data)
276+
277+
269278
const renderComponentDetailsView = () => {
270279
if (hierarchy) {
271280
return <RenderingFrequency data={data.componentData} />;

src/app/styles/base/_base.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,4 @@ body {
4242
.saveSeriesContainer {
4343
padding-bottom: 15px;
4444
padding-top: 10px;
45-
}
46-
47-
48-
45+
}

src/app/styles/components/_performanceVisx.scss

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,63 +22,35 @@
2222
}
2323

2424
#routes-formcontrol {
25-
width: 10em;
25+
padding: 3px;
2626
margin-left: 50px;
27+
font: 300 13px 'Roboto', sans-serif;
28+
text-align: left;
29+
min-width: 10em;
30+
max-height: 50%;
2731
}
2832

2933
#routes-dropdown {
3034
color: white !important;
31-
margin-bottom: 10px;
35+
background-color: #ff6569 !important;
36+
font: 300 13px 'Roboto', sans-serif;
37+
text-align: left;
3238
}
3339

3440
#routes-select {
3541
color: white !important;
3642
background-color: #ff6569 !important;
37-
font: 300 'Roboto', sans-serif;
43+
font: 300 13px 'Roboto', sans-serif;
44+
text-align: left;
3845
}
3946

4047
#seriesname {
4148
float: right;
4249
width: 220px;
4350
margin-right: 165px;
4451
height: 24px;
45-
4652
}
4753

4854
input:focus, textarea:focus, select:focus{
4955
outline: none;
50-
}
51-
52-
// .routes {
53-
// position: absolute;
54-
// align-items: center;
55-
// text-align: center;
56-
// justify-content: center;
57-
// width: 100px;
58-
// }
59-
60-
// .devRoutes {
61-
// padding: 3px;
62-
// outline: transparent;
63-
// color: white;
64-
// display: flex;
65-
// justify-content: center;
66-
// align-items: center;
67-
// text-align: center;
68-
// border-style: solid;
69-
// border-color: transparent;
70-
// border-radius: 3px;
71-
// cursor: pointer;
72-
// line-height: 1.5em;
73-
// font: 300 28px 'Roboto', sans-serif;
74-
// font-size: $button-text-size;
75-
// width: 80px;
76-
// background: $red-color-gradient;
77-
// height: 30px;
78-
// position: absolute;
79-
// left: 2.5rem;
80-
81-
// &.animate {
82-
// background: rgb(41, 164, 41);
83-
// }
84-
// }
56+
}

0 commit comments

Comments
 (0)