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
91498e8d
Commit
91498e8d
authored
Jun 02, 2021
by
Your Name
Committed by
zhaochengxiang
Jun 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finetune
parent
fbec2c8f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
Relation.jsx
src/view/Manage/Map/Component/Relation.jsx
+12
-13
No files found.
src/view/Manage/Map/Component/Relation.jsx
View file @
91498e8d
...
@@ -341,13 +341,13 @@ G6.registerEdge(
...
@@ -341,13 +341,13 @@ 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
rw
=
20
,
rh
=
10
const
rw
=
20
,
rh
=
6
const
rect
=
group
.
addShape
(
'rect'
,
{
// 文字的
边
框
const
rect
=
group
.
addShape
(
'rect'
,
{
// 文字的
底
框
attrs
:
{
attrs
:
{
width
:
rw
,
width
:
rw
,
height
:
rh
,
height
:
rh
,
fill
:
'#fff'
,
fill
:
'#fff'
,
radius
:
5
,
radius
:
2
,
// x and y should be minus width / 2 and height / 2 respectively to translate the center of the rect to the midPoint
// x and y should be minus width / 2 and height / 2 respectively to translate the center of the rect to the midPoint
// x 和 y 分别减去 width / 2 与 height / 2,使矩形中心在 midPoint 上
// x 和 y 分别减去 width / 2 与 height / 2,使矩形中心在 midPoint 上
},
},
...
@@ -359,11 +359,10 @@ G6.registerEdge(
...
@@ -359,11 +359,10 @@ G6.registerEdge(
rect
.
setMatrix
(
toMatrix
)
rect
.
setMatrix
(
toMatrix
)
}
}
{
{
const
text
=
group
.
addShape
(
'text'
,
{
// 文字
的边框
const
text
=
group
.
addShape
(
'text'
,
{
// 文字
attrs
:
{
attrs
:
{
text
:
'关系'
,
text
:
'关系'
,
textAlign
:
'center'
,
textAlign
:
'center'
,
// textBaseLine: 'alphabetic',
fontSize
:
4
,
fontSize
:
4
,
fill
:
'#000'
,
fill
:
'#000'
,
opacity
:
0.85
,
opacity
:
0.85
,
...
@@ -371,7 +370,8 @@ G6.registerEdge(
...
@@ -371,7 +370,8 @@ 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
))
text
.
rotateAtPoint
(
midPoint
.
x
,
midPoint
.
y
,
dy
<
0
?
-
rad
:
rad
)
const
radius
=
dy
<
0
?
-
rad
:
rad
text
.
rotateAtPoint
(
midPoint
.
x
,
midPoint
.
y
,
rad
>
Math
.
PI
*
.
5
?
radius
+
Math
.
PI
:
radius
)
}
}
...
@@ -429,20 +429,19 @@ const formatText = (text, length = 5, elipsis = '...') => {
...
@@ -429,20 +429,19 @@ const formatText = (text, length = 5, elipsis = '...') => {
return
text
;
return
text
;
};
};
function
textXY
(
root
,
cfg
)
{
function
textXY
(
root
,
cfg
)
{
const
txtWidth
=
cfg
.
label
.
length
>
5
?
15
:
cfg
.
label
.
length
*
3
const
txtWidth
=
cfg
.
label
.
length
>
5
?
24
:
cfg
.
label
.
length
*
4
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
=
8
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)
const
radX
=
rad
+
txtWidth
const
radX
=
4
+
txtWidth
const
radY
=
rad
+
Math
.
abs
(
Math
.
pow
(
sinAngle
,
Math
.
abs
(
Math
.
round
(
sinAngle
*
50
))))
*
2
0
//Math.pow(Math.E, 80 * Math.log(Math.abs(sinAngle))) * 40
const
radY
=
Math
.
abs
(
Math
.
pow
(
sinAngle
,
Math
.
abs
(
Math
.
round
(
sinAngle
*
50
))))
*
1
0
//Math.pow(Math.E, 80 * Math.log(Math.abs(sinAngle))) * 40
// console.log(angle, rad, txt)
return
[
return
[
// 右侧文字(中间向右侧15px,上下部向左靠20px) : 左侧
// 右侧文字(中间向右侧15px,上下部向左靠20px) : 左侧
radX
*
cosAngle
,
radX
*
cosAngle
,
radY
*
sinAngle
+
(
sinAngle
>
0
?
sinAngle
*
12
:
sinAngle
*
2
)
radY
*
sinAngle
+
(
sinAngle
>
0
?
sinAngle
*
20
:
sinAngle
*
10
)
];
];
}
}
...
...
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