1
1
// @ts -nocheck
2
- import React , { useState } from 'react' ;
3
- import { Group } from '@visx/group' ;
4
- import { hierarchy , Tree } from '@visx/hierarchy' ;
5
- import { LinearGradient } from '@visx/gradient' ;
6
- import { pointRadial } from 'd3-shape' ;
7
- import useForceUpdate from './useForceUpdate' ;
8
- import LinkControls from './LinkControls' ;
9
- import getLinkComponent from './getLinkComponent' ;
10
- import { localPoint } from '@visx/event' ;
11
- import { useTooltip , useTooltipInPortal , TooltipWithBounds } from '@visx/tooltip' ;
12
- import { onHover , onHoverExit } from '../actions/actions' ;
13
- import { useStoreContext } from '../store' ;
2
+ import React , { useState } from "react" ;
3
+ import { Group } from "@visx/group" ;
4
+ import { hierarchy , Tree } from "@visx/hierarchy" ;
5
+ import { LinearGradient } from "@visx/gradient" ;
6
+ import { pointRadial } from "d3-shape" ;
7
+ import useForceUpdate from "./useForceUpdate" ;
8
+ import LinkControls from "./LinkControls" ;
9
+ import getLinkComponent from "./getLinkComponent" ;
10
+ import { localPoint } from "@visx/event" ;
11
+ import {
12
+ useTooltip ,
13
+ useTooltipInPortal ,
14
+ TooltipWithBounds ,
15
+ } from "@visx/tooltip" ;
16
+ import { onHover , onHoverExit } from "../actions/actions" ;
17
+ import { useStoreContext } from "../store" ;
14
18
15
19
const root = hierarchy ( {
16
- name : ' root' ,
20
+ name : " root" ,
17
21
children : [
18
- { name : ' child #1' } ,
22
+ { name : " child #1" } ,
19
23
{
20
- name : ' child #2' ,
24
+ name : " child #2" ,
21
25
children : [
22
- { name : ' grandchild #1' } ,
23
- { name : ' grandchild #2' } ,
24
- { name : ' grandchild #3' } ,
26
+ { name : " grandchild #1" } ,
27
+ { name : " grandchild #2" } ,
28
+ { name : " grandchild #3" } ,
25
29
] ,
26
30
} ,
27
31
] ,
@@ -32,7 +36,6 @@ interface TreeNode {
32
36
children ?: TreeNode [ ] ;
33
37
}
34
38
35
-
36
39
type HierarchyNode = HierarchyPointNode < TreeNode > ;
37
40
38
41
const defaultMargin = { top : 30 , left : 30 , right : 55 , bottom : 70 } ;
@@ -57,9 +60,9 @@ export default function ComponentMap({
57
60
const data : { } = snapshots [ lastNode ] ;
58
61
59
62
// importing custom hooks for the selection tabs.
60
- const [ layout , setLayout ] = useState ( ' cartesian' ) ;
61
- const [ orientation , setOrientation ] = useState ( ' horizontal' ) ;
62
- const [ linkType , setLinkType ] = useState ( ' diagonal' ) ;
63
+ const [ layout , setLayout ] = useState ( " cartesian" ) ;
64
+ const [ orientation , setOrientation ] = useState ( " horizontal" ) ;
65
+ const [ linkType , setLinkType ] = useState ( " diagonal" ) ;
63
66
const [ stepPercent , setStepPercent ] = useState ( 10 ) ;
64
67
65
68
// Declared this variable and assigned it to the useForceUpdate function that forces a state to change causing that component to re-render and display on the map
@@ -75,7 +78,7 @@ export default function ComponentMap({
75
78
76
79
// This sets the starting position for the root node on the maps display. the polar layout sets the root node to the relative center of the display box based on the size of the browser window.
77
80
// the else conditional statements determines the root nodes location either in the left middle or top middle of the browser window relative to the size of the browser.
78
- if ( layout === ' polar' ) {
81
+ if ( layout === " polar" ) {
79
82
origin = {
80
83
x : innerWidth / 2 ,
81
84
y : innerHeight / 2 ,
@@ -84,7 +87,7 @@ export default function ComponentMap({
84
87
sizeHeight = Math . min ( innerWidth , innerHeight ) / 2 ;
85
88
} else {
86
89
origin = { x : 0 , y : 0 } ;
87
- if ( orientation === ' vertical' ) {
90
+ if ( orientation === " vertical" ) {
88
91
sizeWidth = innerWidth ;
89
92
sizeHeight = innerHeight ;
90
93
} else {
@@ -93,8 +96,7 @@ export default function ComponentMap({
93
96
}
94
97
}
95
98
96
-
97
- //Tooltip stuff:
99
+ //Tooltip stuff:
98
100
const {
99
101
tooltipData,
100
102
tooltipLeft,
@@ -108,16 +110,15 @@ export default function ComponentMap({
108
110
109
111
//mousing controls
110
112
const handleMouseOver = ( event ) => {
111
- console . log ( "mouse entered" ) ;
113
+ // console.log("mouse entered");
112
114
const coords = localPoint ( event . target . ownerSVGElement , event ) ;
113
- console . log ( "I'm coords" , coords ) ;
115
+ // console.log("I'm coords", coords);
114
116
showTooltip ( {
115
117
tooltipLeft : coords . x ,
116
118
tooltipTop : coords . y ,
117
- tooltipData : "test"
119
+ tooltipData : "test" ,
118
120
} ) ;
119
- }
120
-
121
+ } ;
121
122
122
123
// controls for the map
123
124
const LinkComponent = getLinkComponent ( { layout, linkType, orientation } ) ;
@@ -168,11 +169,11 @@ export default function ComponentMap({
168
169
169
170
let top : number ;
170
171
let left : number ;
171
- if ( layout === ' polar' ) {
172
+ if ( layout === " polar" ) {
172
173
const [ radialX , radialY ] = pointRadial ( node . x , node . y ) ;
173
174
top = radialY ;
174
175
left = radialX ;
175
- } else if ( orientation === ' vertical' ) {
176
+ } else if ( orientation === " vertical" ) {
176
177
top = node . y ;
177
178
left = node . x ;
178
179
} else {
@@ -200,10 +201,10 @@ export default function ComponentMap({
200
201
width = { width }
201
202
y = { - height / 2 }
202
203
x = { - width / 2 }
203
- fill = { node . children ? ' #161521' : ' #62d6fb' }
204
- stroke = { node . children ? ' #62d6fb' : ' #161521' }
204
+ fill = { node . children ? " #161521" : " #62d6fb" }
205
+ stroke = { node . children ? " #62d6fb" : " #161521" }
205
206
strokeWidth = { 1 }
206
- strokeDasharray = { node . children ? '0' : ' 2,2' }
207
+ strokeDasharray = { node . children ? "0" : " 2,2" }
207
208
strokeOpacity = "1"
208
209
rx = { node . children ? 4 : 10 }
209
210
onClick = { ( ) => {
@@ -222,13 +223,13 @@ export default function ComponentMap({
222
223
fontSize = { 10 }
223
224
fontFamily = "Roboto"
224
225
textAnchor = "middle"
225
- style = { { pointerEvents : ' none' } }
226
+ style = { { pointerEvents : " none" } }
226
227
fill = {
227
228
node . depth === 0
228
- ? ' #161521'
229
+ ? " #161521"
229
230
: node . children
230
- ? ' white'
231
- : ' #161521'
231
+ ? " white"
232
+ : " #161521"
232
233
}
233
234
>
234
235
{ node . data . name }
@@ -241,7 +242,7 @@ export default function ComponentMap({
241
242
</ Tree >
242
243
</ Group >
243
244
</ svg >
244
- tooltipOpen && tooltipData && (
245
+ { tooltipOpen && tooltipData && (
245
246
< TooltipInPortal
246
247
// set this to random so it correctly updates with parent bounds
247
248
key = { Math . random ( ) }
@@ -250,7 +251,7 @@ export default function ComponentMap({
250
251
>
251
252
Tooltip Data: < strong > { tooltipData } </ strong >
252
253
</ TooltipInPortal >
253
- )
254
+ ) }
254
255
</ div >
255
256
) ;
256
257
}
0 commit comments