【发布时间】:2020-04-12 20:18:39
【问题描述】:
我想要许多节点形状(圆形、方形...)这是我的JSfiddle prototype 问题是箭头放置:
它们在js中是这样创建的:
svg.append('svg:defs').append('svg:marker')
.attr('id', 'end-arrow')
.attr('viewBox', '0 -5 10 10')
.attr('refX', 6)
.attr('markerWidth', 3)
.attr('markerHeight', 3)
.attr('orient', 'auto')
.append('svg:path')
.attr('d', 'M0,-5L10,0L0,5')
.attr('fill', 'red');
//...
var link = svg.selectAll(".link")
.data(graph.links)
.enter().append("line")
.attr("class", "link");
和css:
.link {
stroke: #7a4e4e;
stroke-width: 3px;
stroke-opacity: 1;
marker-end: url(#end-arrow);
}
箭头应该是我画绿色标记的地方,但它们在中心(红色标记)。它们的方向正确,但放错了位置。 d3js中如何让箭头在link-edge和node的交点上?
【问题讨论】:
标签: d3.js graph rendering arrows webcola