Skip to content

Commit d3b1488

Browse files
completed pseudocode and connection/stability update merge. Comparison working as original
1 parent 7af1477 commit d3b1488

File tree

5 files changed

+151
-148
lines changed

5 files changed

+151
-148
lines changed

src/app/components/Action.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ import { ActionProps, OptionsCursorTrueWithMargin } from '../FrontendTypes';
2929
const Action = (props: ActionProps): JSX.Element => {
3030
// We destructure the 'props' that were passed into this component
3131
const {
32-
selected, // boolean on whether the current index is the same as the viewIndex from 'ActionContainer'
33-
last, // boolean on (whether the view index is less than 0) AND if (the index is the same as the last snapshot's index value in hierarchyArr) from 'ActionContainer'
32+
selected, // boolean on whether the current index is the same as the viewIndex in 'ActionContainer'
33+
last, // boolean on (whether the view index is less than 0) AND if (the index is the same as the last snapshot's index value in hierarchyArr) in 'ActionContainer'
3434
index, // from snapshot.index in "ActionContainer's" 'hierarchyArr'
35-
sliderIndex, // from tabs[currentTab] object from 'ActionContainer'
35+
sliderIndex, // from tabs[currentTab] object in 'ActionContainer'
3636
dispatch,
3737
displayName, // from snapshot.displayName in "ActionContainer's" 'hierarchyArr'
3838
componentData, // from snapshot.componentData in "ActionContainer's" 'hierarchyArr'
39-
viewIndex, // from tabs[currentTab] object from 'ActionContainer'
39+
viewIndex, // from tabs[currentTab] object in 'ActionContainer'
4040
isCurrIndex,
4141
handleOnkeyDown, // function that allows arrows keys to jump between snapshots defined in 'ActionContainer.tsx'
4242
} = props;

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ export default function ComponentMap({
9393
hideTooltip // function to close a tooltip
9494
} = useTooltip(); // returns an object with several properties that you can use to manage the tooltip state of your component
9595

96-
const { containerRef, TooltipInPortal } = useTooltipInPortal({
97-
detectBounds: true,
98-
scroll: true,
96+
const {
97+
containerRef, // Access to the container's bounding box. This will be empty on first render.
98+
TooltipInPortal // TooltipWithBounds in a Portal, outside of your component DOM tree
99+
} = useTooltipInPortal({ // Visx hook
100+
detectBounds: true, // use TooltipWithBounds
101+
scroll: true, // when tooltip containers are scrolled, this will correctly update the Tooltip position
99102
});
100103

101104
const tooltipStyles: ToolTipStyles = {

src/app/components/StateRoute/PerformanceVisx/BarGraph.tsx

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -34,49 +34,52 @@ const tooltipStyles = {
3434
const BarGraph = (props: BarGraphProps): JSX.Element => {
3535
const [{ tabs, currentTab }, dispatch] = useStoreContext();
3636
const {
37-
width,
38-
height,
39-
data,
40-
comparison,
41-
setRoute,
42-
allRoutes,
43-
filteredSnapshots,
44-
snapshot,
45-
setSnapshot,
37+
width, // from stateRoute container
38+
height, // from stateRoute container
39+
data, // Acquired from getPerfMetrics(snapshots, getSnapshotIds(hierarchy)) in 'PerformanceVisx'
40+
comparison, // result from invoking 'allStorage' in 'PerformanceVisx'
41+
setRoute, // updates the 'route' state in 'PerformanceVisx'
42+
allRoutes, // array containing urls from 'PerformanceVisx'
43+
filteredSnapshots, // array containing url's that exist and with route === url.pathname
44+
snapshot, // state that is initialized to 'All Snapshots' in 'PerformanceVisx'
45+
setSnapshot, // updates the 'snapshot' state in 'PerformanceVisx'
4646
} = props;
4747
const [seriesNameInput, setSeriesNameInput] = useState(`Series ${comparison.length + 1}`);
48-
const { tooltipOpen, tooltipLeft, tooltipTop, tooltipData, hideTooltip, showTooltip } =
49-
useTooltip<TooltipData>();
48+
const {
49+
tooltipOpen, // boolean whether the tooltip state is open or closed
50+
tooltipLeft, // number used for tooltip positioning
51+
tooltipTop, // number used for tooltip positioning
52+
tooltipData, // value/data that tooltip may need to render
53+
hideTooltip, // function to close a tooltip
54+
showTooltip // function to set tooltip state
55+
} = useTooltip<TooltipData>(); // returns an object with several properties that you can use to manage the tooltip state of your component
5056
let tooltipTimeout: number;
51-
const { containerRef, TooltipInPortal } = useTooltipInPortal({
52-
detectBounds: true,
53-
scroll: true,
57+
const {
58+
containerRef, // Access to the container's bounding box. This will be empty on first render.
59+
TooltipInPortal // TooltipWithBounds in a Portal, outside of your component DOM tree
60+
} = useTooltipInPortal({ // Visx hook
61+
detectBounds: true, // use TooltipWithBounds
62+
scroll: true, // when tooltip containers are scrolled, this will correctly update the Tooltip position
5463
});
5564

5665
const keys = Object.keys(data.componentData);
5766

58-
// data accessor (used to generate scales) and formatter (add units for on hover box)
59-
// d coming from data.barstack post filtered data
60-
const getSnapshotId = (d: snapshot) => d.snapshotId;
67+
const getSnapshotId = (d: snapshot) => d.snapshotId; // data accessor (used to generate scales) and formatter (add units for on hover box). d comes from data.barstack post filtered data
68+
const formatSnapshotId = (id) => `Snapshot ID: ${id}`; // returns snapshot id when invoked in tooltip section
69+
const formatRenderTime = (time) => `${time} ms `; // returns render time when invoked in tooltip section
6170

62-
// returns snapshot id when invoked in tooltip section
63-
const formatSnapshotId = (id) => `Snapshot ID: ${id}`;
64-
// returns render time when invoked in tooltip section
65-
const formatRenderTime = (time) => `${time} ms `;
66-
67-
// create visualization SCALES with cleaned data
68-
const snapshotIdScale = scaleBand<string>({
71+
72+
const snapshotIdScale = scaleBand<string>({ // create visualization SCALES with cleaned data
6973
domain: data.barStack.map(getSnapshotId),
7074
padding: 0.2,
7175
});
7276

73-
// Adjusts y axis to match/ bar height
74-
const renderingScale = scaleLinear<number>({
77+
const renderingScale = scaleLinear<number>({ // Adjusts y axis to match/ bar height
7578
domain: [0, data.maxTotalRender],
7679
nice: true,
7780
});
78-
// Gives each bar on the graph a color using schemeSet1 imported from D3
79-
const colorScale = scaleOrdinal<string>({
81+
82+
const colorScale = scaleOrdinal<string>({ // Gives each bar on the graph a color using schemeSet1 imported from D3
8083
domain: keys,
8184
range: schemeSet1,
8285
});
@@ -92,9 +95,9 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
9295
title: tabs[currentTab].title,
9396
data,
9497
};
95-
// use this to animate the save series button. It
96-
useEffect(() => {
97-
const saveButtons = document.getElementsByClassName('save-series-button');
98+
99+
useEffect(() => { // Animates the save series button.
100+
const saveButtons = document.getElementsByClassName('save-series-button'); // finds the buttom in the DOM
98101
for (let i = 0; i < saveButtons.length; i++) {
99102
if (tabs[currentTab].seriesSavedStatus === 'saved') {
100103
saveButtons[i].classList.add('animate');
@@ -106,22 +109,21 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
106109
}
107110
});
108111

109-
// CURRENTLY DOES NOT SAVE
110-
const saveSeriesClickHandler = () => {
112+
const saveSeriesClickHandler = () => { // function to save the currently selected series
111113
if (tabs[currentTab].seriesSavedStatus === 'inputBoxOpen') {
112114
const actionNames = document.getElementsByClassName('actionname');
113115
for (let i = 0; i < actionNames.length; i += 1) {
114116
toStorage.data.barStack[i].name = actionNames[i].value;
115117
}
116-
dispatch(save(toStorage, seriesNameInput));
117-
setSeriesNameInput(`Series ${comparison.length}`);
118+
dispatch(save(toStorage, seriesNameInput)); // saves the series under seriesName
119+
setSeriesNameInput(`Series ${comparison.length}`); // sends a reducer that saves the series/toStorage object the user wants to chrome local storage
118120
return;
119121
}
120-
dispatch(save(toStorage));
122+
dispatch(save(toStorage)); // sends a reducer that saves the series/toStorage object the user wants to chrome local storage
121123
};
122124

123-
// Need to change so textbox isn't empty before saving
124-
const textbox =
125+
126+
const textbox = // Need to change so textbox isn't empty before saving
125127
tabs[currentTab].seriesSavedStatus === 'inputBoxOpen' ? (
126128
<input
127129
type='text'
@@ -194,8 +196,7 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
194196
{(barStacks) =>
195197
barStacks.map((barStack) =>
196198
barStack.bars.map((bar) => {
197-
// Hides new components if components don't exist in previous snapshots.
198-
if (Number.isNaN(bar.bar[1]) || bar.height < 0) {
199+
if (Number.isNaN(bar.bar[1]) || bar.height < 0) { // Hides new components if components don't exist in previous snapshots.
199200
bar.height = 0;
200201
}
201202
return (
@@ -207,17 +208,15 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
207208
width={bar.width}
208209
fill={bar.color}
209210
/* TIP TOOL EVENT HANDLERS */
210-
// Hides tool tip once cursor moves off the current rect.
211-
onMouseLeave={() => {
211+
onMouseLeave={() => { // Hides tool tip once cursor moves off the current rect.
212212
dispatch(
213213
onHoverExit(data.componentData[bar.key].rtid),
214214
(tooltipTimeout = window.setTimeout(() => {
215215
hideTooltip();
216216
}, 300)),
217217
);
218218
}}
219-
// Cursor position in window updates position of the tool tip.
220-
onMouseMove={(event) => {
219+
onMouseMove={(event) => { // Cursor position in window updates position of the tool tip.
221220
dispatch(onHover(data.componentData[bar.key].rtid));
222221
if (tooltipTimeout) clearTimeout(tooltipTimeout);
223222
const top;
@@ -283,10 +282,7 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
283282
)}
284283
</svg>
285284
{/* FOR HOVER OVER DISPLAY */}
286-
{/* Ths conditional statement displays a different tooltip
287-
configuration depending on if we are trying do display a specific
288-
snapshot through options menu or all snapshots together in bargraph */}
289-
{tooltipOpen && tooltipData && (
285+
{tooltipOpen && tooltipData && ( // Ths conditional statement displays a different tooltip configuration depending on if we are trying do display a specific snapshot through options menu or all snapshots together in bargraph
290286
<TooltipInPortal
291287
key={Math.random()} // update tooltip bounds each render
292288
top={tooltipTop}
@@ -297,8 +293,8 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
297293
{' '}
298294
<strong>{tooltipData.key}</strong>{' '}
299295
</div>
300-
<div>{data.componentData[tooltipData.key].stateType}</div>
301-
<div> {formatRenderTime(tooltipData.bar.data[tooltipData.key])} </div>
296+
<div>{'State: ' + data.componentData[tooltipData.key].stateType}</div>
297+
<div> {'Render time: ' + formatRenderTime(tooltipData.bar.data[tooltipData.key])} </div>
302298
<div>
303299
{' '}
304300
<small>{formatSnapshotId(getSnapshotId(tooltipData.bar.data))}</small>

0 commit comments

Comments
 (0)