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
0b1723e5
Commit
0b1723e5
authored
May 19, 2021
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整连线锚点位置
parent
a9576742
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
12 deletions
+39
-12
Relation.jsx
src/view/Manage/Map/Component/Relation.jsx
+39
-12
No files found.
src/view/Manage/Map/Component/Relation.jsx
View file @
0b1723e5
import
React
from
'react'
;
import
React
from
'react'
;
import
G6
from
'@antv/g6'
;
import
G6
from
'@antv/g6'
;
import
{
isNumber
}
from
'@antv/util'
;
// import { ContextPath } from '../../../../util';
// import { ContextPath } from '../../../../util';
const
colors
=
[
const
colors
=
[
...
@@ -57,22 +57,22 @@ class Relation extends React.Component {
...
@@ -57,22 +57,22 @@ class Relation extends React.Component {
G6
.
registerNode
(
G6
.
registerNode
(
'relation-node'
,
'relation-node'
,
{
{
draw
(
cfg
,
group
)
{
draw
(
cfg
,
group
)
{
let
[
x
,
y
]
=
[
0
,
0
]
let
[
x
,
y
]
=
[
0
,
0
]
if
(
cfg
.
depth
===
0
)
{
if
(
cfg
.
depth
===
0
)
{
root
=
cfg
root
=
cfg
radius
=
cfg
.
children
?.
length
>
10
radius
=
cfg
.
children
?.
length
>
10
}
else
{
}
else
{
[
x
,
y
]
=
textXY
(
root
,
cfg
)
[
x
,
y
]
=
textXY
(
root
,
cfg
)
}
}
group
.
addShape
(
'circle'
,
{
const
circle
=
group
.
addShape
(
'circle'
,
{
attrs
:
{
attrs
:
{
x
:
0
,
x
:
0
,
y
:
0
,
y
:
0
,
r
:
(
radius
&&
cfg
.
depth
!==
0
)
?
10
:
cfg
.
size
/
4
,
r
:
(
radius
&&
cfg
.
depth
!==
0
)
?
10
:
cfg
.
size
/
4
,
fill
:
colors
[
cfg
.
depth
%
colors
.
length
],
fill
:
colors
[
cfg
.
depth
%
colors
.
length
],
},
},
});
});
...
@@ -88,7 +88,7 @@ class Relation extends React.Component {
...
@@ -88,7 +88,7 @@ class Relation extends React.Component {
text
:
(
cfg
.
label
||
''
),
text
:
(
cfg
.
label
||
''
),
}
}
});
});
const
bbox
=
text
.
getBBox
();
const
bbox
=
text
.
getBBox
();
if
(
cfg
.
dbType
===
'Root'
||
cfg
.
dbType
===
'Dir'
)
{
if
(
cfg
.
dbType
===
'Root'
||
cfg
.
dbType
===
'Dir'
)
{
...
@@ -115,6 +115,31 @@ class Relation extends React.Component {
...
@@ -115,6 +115,31 @@ class Relation extends React.Component {
}
}
});
});
}
}
cfg
.
anchorPoints
=
[[
0.5
,
0.5
]]
}
else
{
cfg
.
anchorPoints
=
[
[
0
,
0.5
],
//右边
[
0
,
.
7
],
[.
1
,
.
8
],
[.
2
,
.
8
],
[.
3
,
.
8
],
//顶部
[
0
,
.
3
],
[.
1
,
.
2
],
[.
2
,
.
2
],
[.
3
,
.
2
],
//底部
[
1
,
0.5
],
//左边
[
1
,
.
7
],
[.
9
,
.
8
],
[.
8
,
.
8
],
[.
7
,
.
8
],
//顶部
[
1
,
.
3
],
[.
9
,
.
2
],
[.
8
,
.
2
],
[.
7
,
.
2
],
//底部
]
}
}
return
group
;
return
group
;
...
@@ -144,11 +169,11 @@ class Relation extends React.Component {
...
@@ -144,11 +169,11 @@ class Relation extends React.Component {
});
});
graph
=
new
G6
.
TreeGraph
({
graph
=
new
G6
.
TreeGraph
({
container
:
`container
${
type
||
''
}
`
,
container
:
`container
${
type
||
''
}
`
,
animate
:
false
,
width
,
width
,
height
,
height
,
plugins
:
[
tooltip
],
plugins
:
[
tooltip
],
linkCenter
:
true
,
//
linkCenter: true,
maxZoom
:
1
,
maxZoom
:
1
,
modes
:
{
modes
:
{
default
:
[
default
:
[
...
@@ -189,12 +214,13 @@ class Relation extends React.Component {
...
@@ -189,12 +214,13 @@ class Relation extends React.Component {
],
],
},
},
defaultEdge
:
{
defaultEdge
:
{
type
:
'cubic-horizontal'
,
//
type: 'cubic-horizontal',
size
:
2
,
size
:
2
,
color
:
'#e2e2e2'
,
color
:
'#e2e2e2'
,
},
},
});
});
const
fittingString
=
(
str
,
maxWidth
,
fontSize
)
=>
{
const
fittingString
=
(
str
,
maxWidth
,
fontSize
)
=>
{
const
ellipsis
=
'...'
;
const
ellipsis
=
'...'
;
const
ellipsisLength
=
G6
.
Util
.
getTextSize
(
ellipsis
,
fontSize
)[
0
];
const
ellipsisLength
=
G6
.
Util
.
getTextSize
(
ellipsis
,
fontSize
)[
0
];
...
@@ -325,7 +351,7 @@ function textXY(root, cfg) {
...
@@ -325,7 +351,7 @@ function textXY(root, cfg) {
const
{
x
,
y
}
=
cfg
const
{
x
,
y
}
=
cfg
const
_y
=
y
-
root
.
y
,
_x
=
x
-
root
.
x
const
_y
=
y
-
root
.
y
,
_x
=
x
-
root
.
x
const
rad
=
10
const
rad
=
10
const
angle
=
Math
.
atan2
(
_y
,
_x
)
const
angle
=
Math
.
atan2
(
_y
,
_x
)
const
sinAngle
=
Math
.
sin
(
angle
),
cosAngle
=
Math
.
cos
(
angle
)
const
sinAngle
=
Math
.
sin
(
angle
),
cosAngle
=
Math
.
cos
(
angle
)
// console.log(angle, sinAngle, cosAngle)
// console.log(angle, sinAngle, cosAngle)
const
radX
=
rad
const
radX
=
rad
...
@@ -333,7 +359,7 @@ function textXY(root, cfg) {
...
@@ -333,7 +359,7 @@ function textXY(root, cfg) {
// console.log(angle, rad, txt)
// console.log(angle, rad, txt)
return
[
return
[
// 右侧文字(中间向右侧15px,上下部向左靠20px) : 左侧
// 右侧文字(中间向右侧15px,上下部向左靠20px) : 左侧
radX
*
cosAngle
+
(
cosAngle
>
0
?
txtWidth
+
15
-
Math
.
abs
(
sinAngle
*
20
)
:
-
(
txtWidth
+
15
-
Math
.
abs
(
sinAngle
*
20
))),
radX
*
cosAngle
+
(
cosAngle
>
0
?
txtWidth
+
15
-
Math
.
abs
(
sinAngle
*
20
)
:
-
(
txtWidth
+
15
-
Math
.
abs
(
sinAngle
*
20
))),
radY
*
sinAngle
radY
*
sinAngle
];
];
}
}
\ No newline at end of file
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