Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
9ae051cd
Commit
9ae051cd
authored
Jun 02, 2021
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add marker
parent
7f11b3eb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
18 deletions
+32
-18
Relation.jsx
src/view/Manage/Map/Component/Relation.jsx
+32
-18
No files found.
src/view/Manage/Map/Component/Relation.jsx
View file @
9ae051cd
import
React
from
'react'
;
import
React
from
'react'
;
import
G6
from
'@antv/g6'
;
import
G6
from
'@antv/g6'
;
import
{
transform
,
mat3
}
from
'@antv/matrix-util'
;
import
circle
from
'./circle.93e1.png'
import
circle
from
'./circle.93e1.png'
import
node
from
'./node-bg-select.171e.png'
import
node
from
'./node-bg-select.171e.png'
...
@@ -65,7 +64,7 @@ function countDepth(node, _depth = 0) {
...
@@ -65,7 +64,7 @@ function countDepth(node, _depth = 0) {
function
init
(
container
,
data
)
{
function
init
(
container
,
data
)
{
depthCount
=
{}
depthCount
=
{}
countDepth
(
data
)
countDepth
(
data
)
console
.
debug
(
depthCount
)
//
console.debug(depthCount)
// const container = document.getElementById('container');
// const container = document.getElementById('container');
const
width
=
container
.
scrollWidth
;
const
width
=
container
.
scrollWidth
;
const
height
=
container
.
scrollHeight
||
500
;
const
height
=
container
.
scrollHeight
||
500
;
...
@@ -177,8 +176,7 @@ G6.registerNode(
...
@@ -177,8 +176,7 @@ G6.registerNode(
}
}
if
(
depthCount
[
cfg
.
depth
]
>
10
)
{
if
(
depthCount
[
cfg
.
depth
]
>
10
)
{
group
.
addShape
(
'image'
,
{
const
image
=
group
.
addShape
(
'image'
,
{
attrs
:
{
attrs
:
{
x
:
-
width1
/
2
,
x
:
-
width1
/
2
,
y
:
-
width1
/
2
,
y
:
-
width1
/
2
,
...
@@ -189,7 +187,6 @@ G6.registerNode(
...
@@ -189,7 +187,6 @@ G6.registerNode(
name
:
'halo-shape'
,
name
:
'halo-shape'
,
visible
:
false
,
visible
:
false
,
});
});
}
}
if
(
depthCount
[
cfg
.
depth
]
>
10
)
{
if
(
depthCount
[
cfg
.
depth
]
>
10
)
{
...
@@ -305,10 +302,10 @@ G6.registerNode(
...
@@ -305,10 +302,10 @@ G6.registerNode(
focus
&&
focus
.
hide
();
focus
&&
focus
.
hide
();
}
}
// 将相关边也高亮
// 将相关边也高亮
const
relatedEdges
=
item
.
getEdges
();
//
const relatedEdges = item.getEdges();
relatedEdges
.
forEach
((
edge
)
=>
{
//
relatedEdges.forEach((edge) => {
edge
.
setState
(
'focus'
,
value
);
//
edge.setState('focus', value);
});
//
});
}
}
},
},
update
:
undefined
,
update
:
undefined
,
...
@@ -324,11 +321,12 @@ G6.registerEdge(
...
@@ -324,11 +321,12 @@ G6.registerEdge(
const
startPoint
=
cfg
.
startPoint
;
const
startPoint
=
cfg
.
startPoint
;
const
endPoint
=
cfg
.
endPoint
;
const
endPoint
=
cfg
.
endPoint
;
const
dx
=
endPoint
.
x
-
startPoint
.
x
,
dy
=
endPoint
.
y
-
startPoint
.
y
,
dst
=
Math
.
sqrt
(
dx
*
dx
+
dy
*
dy
)
const
dx
=
endPoint
.
x
-
startPoint
.
x
,
dy
=
endPoint
.
y
-
startPoint
.
y
,
dst
=
Math
.
sqrt
(
dx
*
dx
+
dy
*
dy
)
const
px
=
dst
>
30
?
10
*
dx
/
dst
:
0
,
py
=
dst
>
30
?
10
*
dy
/
dst
:
0
const
px
=
dst
>
30
?
10
*
dx
/
dst
:
0
,
py
=
dst
>
30
?
10
*
dy
/
dst
:
0
const
shape
=
group
.
addShape
(
'path'
,
{
const
shape
=
group
.
addShape
(
'path'
,
{
// 自定义连线
attrs
:
{
attrs
:
{
stroke
:
'#aaa'
,
stroke
:
'#aaa'
,
lineWidth
:
.
5
,
path
:
[
path
:
[
[
'M'
,
startPoint
.
x
+
px
,
startPoint
.
y
+
py
],
[
'M'
,
startPoint
.
x
+
px
,
startPoint
.
y
+
py
],
[
'L'
,
endPoint
.
x
-
px
,
endPoint
.
y
-
py
],
[
'L'
,
endPoint
.
x
-
px
,
endPoint
.
y
-
py
],
...
@@ -339,9 +337,10 @@ G6.registerEdge(
...
@@ -339,9 +337,10 @@ G6.registerEdge(
});
});
const
midPoint
=
shape
.
getPoint
(
0.5
);
const
midPoint
=
shape
.
getPoint
(
0.5
);
const
rad
=
Math
.
acos
(
dx
/
dst
)
const
rad
=
Math
.
acos
(
dx
/
dst
)
{
const
radius
=
dy
<
0
?
-
rad
:
rad
const
rw
=
20
,
rh
=
6
const
rw
=
20
,
rh
=
6
{
const
rect
=
group
.
addShape
(
'rect'
,
{
// 文字的底框
const
rect
=
group
.
addShape
(
'rect'
,
{
// 文字的底框
attrs
:
{
attrs
:
{
width
:
rw
,
width
:
rw
,
...
@@ -354,7 +353,7 @@ G6.registerEdge(
...
@@ -354,7 +353,7 @@ G6.registerEdge(
});
});
const
toMatrix
=
G6
.
Util
.
transform
(
const
toMatrix
=
G6
.
Util
.
transform
(
[
1
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
1
],
[
1
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
1
],
[[
't'
,
-
rw
>>
1
,
-
rh
>>
1
],[
'r'
,
dy
<
0
?
-
rad
:
rad
],[
't'
,
midPoint
.
x
,
midPoint
.
y
]],
[[
't'
,
-
rw
>>
1
,
-
rh
>>
1
],
[
'r'
,
dy
<
0
?
-
rad
:
rad
],
[
't'
,
midPoint
.
x
,
midPoint
.
y
]],
);
);
rect
.
setMatrix
(
toMatrix
)
rect
.
setMatrix
(
toMatrix
)
}
}
...
@@ -369,11 +368,26 @@ G6.registerEdge(
...
@@ -369,11 +368,26 @@ G6.registerEdge(
}
}
})
})
const
bbox
=
text
.
getBBox
()
const
bbox
=
text
.
getBBox
()
text
.
moveTo
(
midPoint
.
x
,
midPoint
.
y
+
(
bbox
.
height
>>
1
))
text
.
moveTo
(
midPoint
.
x
,
midPoint
.
y
+
(
bbox
.
height
>>
1
))
const
radius
=
dy
<
0
?
-
rad
:
rad
text
.
rotateAtPoint
(
midPoint
.
x
,
midPoint
.
y
,
rad
>
Math
.
PI
*
.
5
?
radius
+
Math
.
PI
:
radius
)
text
.
rotateAtPoint
(
midPoint
.
x
,
midPoint
.
y
,
rad
>
Math
.
PI
*
.
5
?
radius
+
Math
.
PI
:
radius
)
}
}
{
const
arrow
=
group
.
addShape
(
'marker'
,
{
attrs
:
{
x
:
0
,
y
:
0
,
r
:
2
,
fill
:
'#fff'
,
symbol
:
'triangle'
,
},
// must be assigned in G6 3.3 and later versions. it can be any value you want
name
:
'marker-shape'
,
});
const
x
=
midPoint
.
x
+
((
rw
>>
1
)
+
2.5
)
*
dx
/
dst
,
y
=
midPoint
.
y
+
((
rw
>>
1
)
+
2.5
)
*
dy
/
dst
arrow
.
moveTo
(
x
,
y
)
arrow
.
rotateAtPoint
(
x
,
y
,
radius
+
Math
.
PI
*
.
5
)
}
return
group
;
return
group
;
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment