Skip to content

Commit 2dc08c8

Browse files
committed
adjusted nodeLength values to test spacing for ax tree nodes in accessibility tab
1 parent 1f20b70 commit 2dc08c8

File tree

1 file changed

+14
-49
lines changed
  • src/app/components/StateRoute/AxMap

1 file changed

+14
-49
lines changed

src/app/components/StateRoute/AxMap/Ax.tsx

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Group } from '@visx/group';
33
import { hierarchy, Tree } from '@visx/hierarchy';
44
import { LinearGradient } from '@visx/gradient';
55
import { pointRadial } from 'd3-shape';
6+
import { useTooltipInPortal } from '@visx/tooltip';
67
import LinkControls from './axLinkControls';
78
import getLinkComponent from './getAxLinkComponents';
89

@@ -203,51 +204,6 @@ export default function AxTree(props) {
203204
// // array that holds the ax tree as a nested object and the root node initially
204205
const nodeAxArr = [];
205206

206-
// code handling the initial root case / if there is only 1 child
207-
// condition checking if the last node added has childIds length > 0
208-
209-
// function to handle nesting past the root node
210-
// const organizeAxTree = (currNode, currAxSnapshot) => {
211-
// for (let i = 0; i < currNode.length; i++) {
212-
// if (currNode[i].childIds.length > 0) {
213-
// currNode[i].children = [];
214-
215-
// for (let j = 0; j < currAxSnapshot.length; j++) {
216-
217-
// if (currNode[i].childIds.includes(currAxSnapshot[j].nodeId)) {
218-
// currNode[i].children.push(currAxSnapshot[j]);
219-
220-
// organizeAxTree(currNode[i].children, currAxSnapshot);
221-
// }
222-
// }
223-
// }
224-
// }
225-
// }
226-
// organizeAxTree(nodeAxArr, currAxSnapshot);
227-
228-
// const organizeAxTree = (currNodeArr, currAxSnapshot, i = 0) => {
229-
// console.log('currNode: ', currNodeArr);
230-
// // handles each child node within the children property
231-
// while (currNodeArr[i]) {
232-
// if (currNodeArr[i].childIds) {
233-
// currNodeArr[i].children = [];
234-
// // iterate through every snapshot in currAxSnapshot
235-
// for (let j = 0; j < currAxSnapshot.length; j++) {
236-
// // includes does not have good time complexity, can convert to nested for or for of loop
237-
// for (const childEle of currNodeArr[i].childIds) {
238-
// if (childEle === currAxSnapshot[j].nodeId) {
239-
// currNodeArr[i].children.push(currAxSnapshot[j]);
240-
// }
241-
// }
242-
// }
243-
// }
244-
// i++;
245-
// }
246-
// i = 0;
247-
// organizeAxTree(currNodeArr[i].children, currAxSnapshot);
248-
// }
249-
250-
// if (currNode.childIds) {
251207
// currNode.children = [];
252208
// // checks if there is more than 1 child
253209
// if (currNode.childIds.length > 1) {
@@ -310,6 +266,14 @@ export default function AxTree(props) {
310266
populateNodeAxArr(rootAxNode);
311267
console.log('nodeAxArr: ', nodeAxArr);
312268

269+
const {
270+
containerRef // Access to the container's bounding box. This will be empty on first render.
271+
} = useTooltipInPortal({
272+
// Visx hook
273+
detectBounds: true, // use TooltipWithBounds
274+
scroll: true, // when tooltip containers are scrolled, this will correctly update the Tooltip position
275+
});
276+
313277
return totalWidth < 10 ? null : (
314278
<div>
315279
<LinkControls
@@ -324,7 +288,7 @@ export default function AxTree(props) {
324288
/>
325289

326290
{/* svg references purple background */}
327-
<svg width={totalWidth} height={totalHeight + 0}>
291+
<svg ref={containerRef} width={totalWidth} height={totalHeight + 0}>
328292
<LinearGradient id='root-gradient' from='#488689' to='#3c6e71' />
329293
<LinearGradient id='parent-gradient' from='#488689' to='#3c6e71' />
330294
<rect
@@ -346,6 +310,7 @@ export default function AxTree(props) {
346310
key={i}
347311
data={link}
348312
percent={stepPercent}
313+
stroke="rgb(254,110,158,0.6)"
349314
strokeWidth="1"
350315
fill="none"
351316
/>
@@ -357,9 +322,9 @@ export default function AxTree(props) {
357322
//returns a number that is related to the length of the name. Used for determining the node width.
358323
const nodeLength = name.length;
359324
//return nodeLength * 7 + 20; //uncomment this line if we want each node to be directly proportional to the name.length (instead of nodes of similar sizes to snap to the same width)
360-
if (nodeLength <= 5) return nodeLength + 50;
361-
if (nodeLength <= 10) return nodeLength + 120;
362-
return nodeLength + 180;
325+
if (nodeLength <= 5) return nodeLength + 60;
326+
if (nodeLength <= 10) return nodeLength + 130;
327+
return nodeLength + 160;
363328
};
364329

365330
const width: number = widthFunc(node.data.name.value); // the width is determined by the length of the node.name

0 commit comments

Comments
 (0)