【发布时间】:2019-06-14 11:46:23
【问题描述】:
我的链接代码如下:
const links = d3
.select('svg g.links')
.selectAll('line.link')
.data(root.links())
.enter();
links
.append('path')
.classed('link', true)
.attr('d', this.buildCurvedNodesJointLine);
buildCurvedNodesJointLine(d) {
if (d.target.data.noParent) {
return 'M0,0L0,0';
}
const ny = d.target.y + (d.source.y - d.target.y) * 0.5;
const linedata: any = [
{
x: d.target.x,
y: d.target.y
},
{
x: d.target.x,
y: ny
},
{
x: d.source.x,
y: d.source.y
}
];
const fun = d3
.line()
.x((data1: any) => data1.x)
.y((data2: any) => data2.y)
.curve(d3.curveStepAfter);
return fun(linedata);
buildCurvedNodesJointLine 函数为我的节点构建曲线链接。
但我不能在链接行的末尾添加方向箭头。所以它可能看起来像这样:
【问题讨论】:
-
您似乎想使用
linedata数组中的最后一个元素来定位您的箭头。对于箭头本身,您可以在该点附加 SVG polygon。
标签: javascript angular d3.js