Javascript &引用;标记中间“;无法使用路径d3.js强制布局
如何在force布局中的链接(路径svg)上附加“标记mid” 这是我的密码:Javascript &引用;标记中间“;无法使用路径d3.js强制布局,javascript,svg,d3.js,Javascript,Svg,D3.js,如何在force布局中的链接(路径svg)上附加“标记mid” 这是我的密码: var path = d3.select('.pitch').selectAll("path") .data(force.links()) .enter() .append('g') .classed('g_path', true) .append("svg:path") .
var path = d3.select('.pitch').selectAll("path")
.data(force.links())
.enter()
.append('g')
.classed('g_path', true)
.append("svg:path")
.attr("class", "link").attr("marker-mid", function(d) {
return "url(#BLUE)"
});
您需要添加到svg中,以创建要作为标记的元素和用于设置矩形样式的类“box”
svg.append("defs")
.append("marker")
.attr("id", "BLUE")
.attr("viewBox", "0 0 10 10")
.attr("refX", 5 )
.attr("refY", 5)
.attr("markerWidth", 10)
.attr("markerHeight", 10)
.attr("orient", "auto")
.attr("class","box")
.append("rect")
.style("width","5px")
.style("height","5px")