Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript &引用;标记中间“;无法使用路径d3.js强制布局_Javascript_Svg_D3.js - Fatal编程技术网

Javascript &引用;标记中间“;无法使用路径d3.js强制布局

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") .

如何在force布局中的链接(路径svg)上附加“标记mid”

这是我的密码:

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")