|
@@ -607,6 +607,13 @@ function renderWalkedLayer() {
|
|
|
.attr('stroke-width', d => getEdgeStyle({ type: d.type, score: d.score }).strokeWidth)
|
|
.attr('stroke-width', d => getEdgeStyle({ type: d.type, score: d.score }).strokeWidth)
|
|
|
.attr('stroke-dasharray', d => getEdgeStyle({ type: d.type, score: d.score }).strokeDasharray)
|
|
.attr('stroke-dasharray', d => getEdgeStyle({ type: d.type, score: d.score }).strokeDasharray)
|
|
|
.attr('d', d => {
|
|
.attr('d', d => {
|
|
|
|
|
+ // 同一层的边(Y坐标相近)用向下弯曲的曲线
|
|
|
|
|
+ if (Math.abs(d.srcY - d.tgtY) < 10) {
|
|
|
|
|
+ const controlY = d.srcY + 50 // 向下弯曲
|
|
|
|
|
+ const midX = (d.srcX + d.tgtX) / 2
|
|
|
|
|
+ return `M${d.srcX},${d.srcY} Q${midX},${controlY} ${d.tgtX},${d.tgtY}`
|
|
|
|
|
+ }
|
|
|
|
|
+ // 不同层的边用 S 形曲线
|
|
|
const midY = (d.srcY + d.tgtY) / 2
|
|
const midY = (d.srcY + d.tgtY) / 2
|
|
|
return `M${d.srcX},${d.srcY} C${d.srcX},${midY} ${d.tgtX},${midY} ${d.tgtX},${d.tgtY}`
|
|
return `M${d.srcX},${d.srcY} C${d.srcX},${midY} ${d.tgtX},${midY} ${d.tgtX},${d.tgtY}`
|
|
|
})
|
|
})
|
|
@@ -619,7 +626,8 @@ function renderWalkedLayer() {
|
|
|
.attr('class', 'walked-score')
|
|
.attr('class', 'walked-score')
|
|
|
.attr('transform', d => {
|
|
.attr('transform', d => {
|
|
|
const midX = (d.srcX + d.tgtX) / 2
|
|
const midX = (d.srcX + d.tgtX) / 2
|
|
|
- const midY = (d.srcY + d.tgtY) / 2
|
|
|
|
|
|
|
+ // 同一层的边,分数标签放在曲线最低点
|
|
|
|
|
+ const midY = Math.abs(d.srcY - d.tgtY) < 10 ? d.srcY + 50 : (d.srcY + d.tgtY) / 2
|
|
|
return `translate(${midX}, ${midY})`
|
|
return `translate(${midX}, ${midY})`
|
|
|
})
|
|
})
|
|
|
|
|
|