Skip to content

Commit a602a22

Browse files
committed
alternate snapshot data to fit new snapshot graph, fixed scaling of the graph.
Co-authored-by: OzairGh <https://github.com/OzairGh> Co-authored-by: Khanh <https://github.com/AndyB909>
1 parent 984b6f1 commit a602a22

File tree

3 files changed

+58
-13
lines changed

3 files changed

+58
-13
lines changed

src/app/components/BarGraph.tsx

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const tooltipStyles = {
6262
const BarGraph = props => {
6363
const [{ tabs, currentTab }, dispatch] = useStoreContext();
6464
const {
65+
maxHeight,
6566
width,
6667
height,
6768
data,
@@ -138,12 +139,20 @@ const BarGraph = props => {
138139
});
139140

140141
// setting max dimensions and scale ranges
142+
143+
// if (snapshot !== 'All Snapshots') {
144+
// // let oldHeight = height
145+
// height = maxHeight * 50 * 2 + margin.top + 150;
146+
// }
147+
141148
const xMax = width - margin.left - margin.right;
142-
const yMax = height - margin.top - 150;
143149
snapshotIdScale.rangeRound([0, xMax]);
150+
const yMax = height - margin.top - 150;
144151
renderingScale.range([yMax, 0]);
145152

146-
// componentScale.rangeRound([0, xMax]);
153+
console.log(height, '<--height');
154+
console.log(yMax, '<--yMax');
155+
console.log(maxHeight, '<--maxHeight');
147156

148157
const toStorage = {
149158
currentTab,
@@ -156,7 +165,7 @@ const BarGraph = props => {
156165
for (let i = 0; i < saveButtons.length; i++) {
157166
if (tabs[currentTab].seriesSavedStatus === 'saved') {
158167
saveButtons[i].classList.add('animate');
159-
console.log('checking saveButtons[i].classList', saveButtons[i].classList)
168+
console.log('checking saveButtons[i].classList', saveButtons[i].classList);
160169
saveButtons[i].innerHTML = 'Saved!';
161170
} else {
162171
saveButtons[i].innerHTML = 'Save Series';
@@ -298,7 +307,15 @@ const BarGraph = props => {
298307
onMouseMove={event => {
299308
dispatch(onHover(data.componentData[bar.key].rtid));
300309
if (tooltipTimeout) clearTimeout(tooltipTimeout);
301-
const top = event.clientY - margin.top - bar.height;
310+
const top;
311+
if (snapshot === 'All Snapshots') {
312+
top = event.clientY - margin.top - bar.height;
313+
} else {
314+
top = event.clientY - margin.top;
315+
}
316+
console.log(event.clientY, '<-- event.clientY');
317+
console.log(bar.height, '<-- bar.height');
318+
console.log(top, '<-- top');
302319
const left = bar.x + bar.width / 2;
303320
showTooltip({
304321
tooltipData: bar,
@@ -341,7 +358,7 @@ const BarGraph = props => {
341358
})}
342359
/>
343360
<Text
344-
x={-xMax / 2}
361+
x={-yMax / 2 - 75}
345362
y="15"
346363
transform="rotate(-90)"
347364
fontSize={12}
@@ -350,9 +367,17 @@ const BarGraph = props => {
350367
Rendering Time (ms)
351368
</Text>
352369
<br />
353-
<Text x={xMax / 2 + 15} y={yMax + 70} fontSize={12} fill="#FFFFFF">
354-
Snapshot ID
355-
</Text>
370+
{(snapshot === 'All Snapshots')
371+
? (
372+
<Text x={xMax / 2 + 15} y={yMax + 70} fontSize={12} fill="#FFFFFF">
373+
Snapshot ID
374+
</Text>
375+
)
376+
: (
377+
<Text x={xMax / 2 + 15} y={yMax + 70} fontSize={12} fill="#FFFFFF">
378+
Components
379+
</Text>
380+
)}
356381

357382
</svg>
358383
{/* FOR HOVER OVER DISPLAY */}

src/app/components/PerformanceVisx.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,20 @@ const PerformanceVisx = (props: BarStackProps) => {
237237

238238
const allRoutes = [];
239239
const filteredSnapshots = [];
240-
240+
// loop through data.barStack
241241
for (let i = 0; i < data.barStack.length; i += 1) {
242+
// set url variable to new route url
242243
const url = new URL(data.barStack[i].route);
244+
// if all the routes do not have the pathname property on url then push it onto all routes array
243245
if (!allRoutes.includes(url.pathname)) {
244246
allRoutes.push(url.pathname);
245247
}
248+
// if the route exists and it is equal to url.pathname then push data.barstack at i into filteredSnapshots array
246249
if (route && route === url.pathname) {
247250
filteredSnapshots.push(data.barStack[i]);
248251
}
249252
}
253+
// if route does not equal to All Routes, set data.barstack to filteredSnapshots array
250254
if (route !== 'All Routes') {
251255
data.barStack = filteredSnapshots;
252256
}
@@ -256,6 +260,7 @@ const PerformanceVisx = (props: BarStackProps) => {
256260
// data.barStack[] // 0: 1.0 snapshot 1: 2.0 snapshot 2: 3.0 snapshot
257261
// data.barStack[{123123},{123123},12312,12312]
258262
// && data.barStack[parseInt(snapshot, 10) - 1]
263+
259264
if (snapshot !== 'All Snapshots') {
260265
// console.log(data.barStack, '<---------data.barstack', snapshot, '<-----snapshot');
261266
// const checkData = [];
@@ -274,9 +279,23 @@ const PerformanceVisx = (props: BarStackProps) => {
274279
// if (comp.snapshotId === snapshot) return comp;
275280
// });
276281
const checkData = [data.barStack.find(comp => comp.snapshotId === snapshot)];
277-
// checkData = checkData.filter(element => { return element !== undefined; })
278-
// console.log(checkData, '<-- checkData');
279-
if (checkData) data.barStack = checkData;
282+
const holdData = [];
283+
// maxheight is referring to the max height in render time to choose the scaling size for graph
284+
let maxHeight = 0;
285+
for (const key in checkData[0]) {
286+
if (key !== 'route' && key !== 'snapshotId') {
287+
if (maxHeight < checkData[0][key]) maxHeight = checkData[0][key];
288+
const name = {};
289+
name[key] = checkData[0][key];
290+
holdData.push(name);
291+
holdData[holdData.length - 1].route = checkData[0].route;
292+
holdData[holdData.length - 1].snapshotId = key;
293+
}
294+
}
295+
data.maxTotalRender = maxHeight * 1.15;
296+
console.log(checkData, '<-- CheckData');
297+
console.log(holdData, '<--holdData');
298+
if (holdData) data.barStack = holdData;
280299
}
281300
// data.barStack = [
282301
// {snapshot: 1.0,
@@ -297,6 +316,7 @@ const PerformanceVisx = (props: BarStackProps) => {
297316
return (
298317
<div>
299318
<BarGraph
319+
maxHeight={maxHeight}
300320
data={data}
301321
width={width}
302322
height={height}

src/extension/build/panel.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
7-
<title>Reactime 14.0</title>
7+
<title>Reactime 15.0</title>
88
</head>
99

1010
<body>

0 commit comments

Comments
 (0)