Skip to content

Commit 34b0573

Browse files
completed History, WebMetrics, ComponentMap, LinkControls, ToolTipDataDisplay, getLinkComponent, Tree
1 parent 7ffd1c5 commit 34b0573

File tree

4 files changed

+32
-26
lines changed

4 files changed

+32
-26
lines changed

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default function ComponentMap({
5858
let sizeHeight: number;
5959

6060
/*
61-
This sets the starting position for the root node on the maps display.
61+
We begin setting the starting position for the root node on the maps display.
6262
The 'polar layout' sets the root node to the relative center of the display box based on the size of the browser window.
6363
The 'cartesian layout' (else conditional) sets the root nodes location either in the left middle *or top middle of the browser window relative to the size of the browser.
6464
*/
@@ -84,7 +84,6 @@ export default function ComponentMap({
8484
}
8585
}
8686

87-
// Tooltip stuff that was destructured from the returned object from 'useTooltip()'
8887
const {
8988
tooltipData, // value/data that tooltip may need to render
9089
tooltipLeft, // number used for tooltip positioning
@@ -128,14 +127,14 @@ export default function ComponentMap({
128127

129128
const nodeList: [] = []; // create a nodeList array to store our nodes as a flat array
130129

131-
const collectNodes: void = (node) => {
132-
nodeList.splice(0, nodeList.length);
133-
nodeList.push(node);
134-
for (let i = 0; i < nodeList.length; i += 1) {
130+
const collectNodes: void = (node) => { // function that takes in a node (snapshot) as it's argument and modifies 'nodeList' so that the node and it's children are all within the flattened 'nodeList'.
131+
nodeList.splice(0, nodeList.length); // deletes all the nodes in nodelist
132+
nodeList.push(node); // pushes the snapshot into nodeList
133+
for (let i = 0; i < nodeList.length; i += 1) { // iterate through the nodeList that contains our snapshot
135134
const cur = nodeList[i];
136-
if (cur.children && cur.children.length > 0) {
137-
for (const child of cur.children) {
138-
nodeList.push(child);
135+
if (cur.children && cur.children.length > 0) { // if the currently itereated snapshot has non-zero children...
136+
for (const child of cur.children) { // iterate through each child in the children array
137+
nodeList.push(child); // add the child to the nodeList
139138
}
140139
}
141140
}
@@ -155,7 +154,7 @@ export default function ComponentMap({
155154
if (startNode === null) startNode = rootNode;
156155
};
157156

158-
findSelectedNode();
157+
findSelectedNode(); // locates the rootNode... do we really need this? This function is only used once... it's here.
159158

160159
// controls for the map
161160
const LinkComponent: React.ComponentType<unknown> = getLinkComponent({ layout, linkType, orientation });
@@ -206,7 +205,7 @@ export default function ComponentMap({
206205
))}
207206

208207
{tree.descendants().map((node, key) => {
209-
const widthFunc:number = (name) => { // function that takes in a node's name and returns a number that is related to the length of the name.
208+
const widthFunc:number = (name) => { // function that takes in a node's name and returns a number that is related to the length of the name. Used for determining the node width.
210209
const nodeLength = name.length;
211210
if (nodeLength <= 5) return nodeLength + 80; // returns a number between 80-85
212211
if (nodeLength <= 10) return nodeLength + 120; // returns a number between 125-130
@@ -260,6 +259,7 @@ export default function ComponentMap({
260259
}}
261260
/>
262261
)}
262+
263263
{/* This creates the rectangle boxes for each component
264264
and sets it relative position to other parent nodes of the same level. */}
265265
{node.depth !== 0 && (
@@ -271,7 +271,7 @@ export default function ComponentMap({
271271
fill={node.children ? '#161521' : '#62d6fb'}
272272
stroke={
273273
node.data.isExpanded && node.data.children.length > 0
274-
? '#F00008' // changed to #F00008 for higher contrast
274+
? '#F00008'
275275
: '#4D4D4D'
276276
}
277277
strokeWidth={1.5}
@@ -281,6 +281,7 @@ export default function ComponentMap({
281281
dispatch(toggleExpanded(node.data));
282282
hideTooltip();
283283
}}
284+
284285
// Mouse Enter Rect (Component Node) -----------------------------------------------------------------------
285286
/** This onMouseEnter event fires when the mouse first moves/hovers over a component node.
286287
* The supplied event listener callback produces a Tooltip element for the current node. */
@@ -317,6 +318,7 @@ export default function ComponentMap({
317318
}}
318319
/>
319320
)}
321+
320322
{/* Display text inside of each component node */}
321323
<text
322324
dy='.33em'

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ export default function LinkControls({
4949
collectNodes(snapShots);
5050

5151
return (
52-
<div style={controlStyles}>
53-
{/* Controls for the layout selection */}
52+
<div style={controlStyles}> {/* Controls for the layout selection */}
5453
<label>Layout:</label>
55-
&nbsp;{' '}
56-
{/* This is a non-breaking space - Prevents an automatic line break at this position */}
54+
&nbsp;{' '} {/* This is a non-breaking space - Prevents an automatic line break at this position */}
5755
<select
5856
onClick={(e) => e.stopPropagation()}
5957
onChange={(e) => setLayout(e.target.value)}
@@ -64,8 +62,8 @@ export default function LinkControls({
6462
<option value='polar'>Polar</option>
6563
</select>
6664
&nbsp;&nbsp;
67-
{/* Controls for the Orientation selection, this dropdown will be disabled when the polar layout is selected as it is not needed */}
68-
<label>Orientation:</label>
65+
66+
<label>Orientation:</label> {/* Controls for the Orientation selection, this dropdown will be disabled when the polar layout is selected as it is not needed */}
6967
&nbsp;
7068
<select
7169
onClick={(e) => e.stopPropagation()}
@@ -77,8 +75,9 @@ export default function LinkControls({
7775
<option value='horizontal'>Horizontal</option>
7876
</select>
7977
&nbsp;&nbsp;
80-
{/* Controls for the link selections. */}
81-
<label>Link:</label>
78+
79+
80+
<label>Link:</label> {/* Controls for the link selections. */}
8281
&nbsp;
8382
<select
8483
onClick={(e) => e.stopPropagation()}
@@ -89,8 +88,9 @@ export default function LinkControls({
8988
<option value='step'>Step</option>
9089
<option value='line'>Line</option>
9190
</select>
92-
{/* Controls for the select selections. */}
93-
<label> Select:</label>
91+
92+
93+
<label> Select:</label> {/* Controls for the select selections. */}
9494
&nbsp;
9595
<select
9696
id='selectInput'
@@ -107,6 +107,7 @@ export default function LinkControls({
107107
),
108108
)}
109109
</select>
110+
110111
{/* This is the slider control for the step option */}
111112
{linkType === 'step' && layout !== 'polar' && (
112113
<>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from 'react';
22
import JSONTree from 'react-json-tree';
33

4+
/*
5+
Code that show's the tooltip of our JSON tree
6+
*/
47

58
const colors = {
69
scheme: 'paraiso',

src/app/components/StateRoute/ComponentMap/getLinkComponent.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import { LinkComponent } from '../../../FrontendTypes'
1616

1717
/*
18-
18+
Changes the shape of the LinkComponent based on the layout, linkType, and orientation
1919
*/
2020

2121
export default function getLinkComponent({
@@ -25,7 +25,7 @@ export default function getLinkComponent({
2525
}: LinkComponent): React.ComponentType<unknown> {
2626
let LinkComponent: React.ComponentType<unknown>;
2727

28-
if (layout === 'polar') {
28+
if (layout === 'polar') { // if the layout is polar, linkType can be either step, curve, line, or a plain LinkRadial.
2929
if (linkType === 'step') {
3030
LinkComponent = LinkRadialStep;
3131
} else if (linkType === 'curve') {
@@ -35,7 +35,7 @@ export default function getLinkComponent({
3535
} else {
3636
LinkComponent = LinkRadial;
3737
}
38-
} else if (orientation === 'vertical') {
38+
} else if (orientation === 'vertical') { // if the layout isn't polar and the orientation is vertical, linkType can be either step, curve, line, or a plain LinkVertical
3939
if (linkType === 'step') {
4040
LinkComponent = LinkVerticalStep;
4141
} else if (linkType === 'curve') {
@@ -45,7 +45,7 @@ export default function getLinkComponent({
4545
} else {
4646
LinkComponent = LinkVertical;
4747
}
48-
} else if (linkType === 'step') {
48+
} else if (linkType === 'step') { // if orientation and layout still haven't matched, linkType will determine our linkComponent type based on if linkType is step, curve, line, or a plain LinkHorizontal
4949
LinkComponent = LinkHorizontalStep;
5050
} else if (linkType === 'curve') {
5151
LinkComponent = LinkHorizontalCurve;

0 commit comments

Comments
 (0)