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
D3.js 去掉边上的箭头_D3.js_Svg - Fatal编程技术网

D3.js 去掉边上的箭头

D3.js 去掉边上的箭头,d3.js,svg,D3.js,Svg,我正在尝试修改。这是代码,在一张纸上 我想做的是删除绿色边缘的箭头。有人知道怎么做吗 <!DOCTYPE html> <meta charset="utf-8"> <style> .link { fill: none; stroke: #666; stroke-width: 1.5px; } #licensing { fill: green; } .link.licensing { stroke: green; } .link.re

我正在尝试修改。这是代码,在一张纸上

我想做的是删除绿色边缘的箭头。有人知道怎么做吗

<!DOCTYPE html>
<meta charset="utf-8">
<style>

.link {
  fill: none;
  stroke: #666;
  stroke-width: 1.5px;
}

#licensing {
  fill: green;
}

.link.licensing {
  stroke: green;
}

.link.resolved {
  stroke-dasharray: 0,2 1;
}

circle {
  fill: #ccc;
  stroke: #333;
  stroke-width: 1.5px;
}

text {
  font: 10px sans-serif;
  pointer-events: none;
  text-shadow: 0 1px 0 #fff, 1px 0 0 #fff, 0 -1px 0 #fff, -1px 0 0 #fff;
}

</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>

// http://blog.thomsonreuters.com/index.php/mobile-patent-suits-graphic-of-the-day/
var links = [
  {source: "Microsoft", target: "Amazon", type: "licensing"},
  {source: "Microsoft", target: "HTC", type: "licensing"},
  {source: "Samsung", target: "Apple", type: "suit"},
  {source: "Motorola", target: "Apple", type: "suit"},
  {source: "Nokia", target: "Apple", type: "resolved"},
  {source: "HTC", target: "Apple", type: "suit"},
  {source: "Kodak", target: "Apple", type: "suit"},
  {source: "Microsoft", target: "Barnes & Noble", type: "suit"},
  {source: "Microsoft", target: "Foxconn", type: "suit"},
  {source: "Oracle", target: "Google", type: "suit"},
  {source: "Apple", target: "HTC", type: "suit"},
  {source: "Microsoft", target: "Inventec", type: "suit"},
  {source: "Samsung", target: "Kodak", type: "resolved"},
  {source: "LG", target: "Kodak", type: "resolved"},
  {source: "RIM", target: "Kodak", type: "suit"},
  {source: "Sony", target: "LG", type: "suit"},
  {source: "Kodak", target: "LG", type: "resolved"},
  {source: "Apple", target: "Nokia", type: "resolved"},
  {source: "Qualcomm", target: "Nokia", type: "resolved"},
  {source: "Apple", target: "Motorola", type: "suit"},
  {source: "Microsoft", target: "Motorola", type: "suit"},
  {source: "Motorola", target: "Microsoft", type: "suit"},
  {source: "Huawei", target: "ZTE", type: "suit"},
  {source: "Ericsson", target: "ZTE", type: "suit"},
  {source: "Kodak", target: "Samsung", type: "resolved"},
  {source: "Apple", target: "Samsung", type: "suit"},
  {source: "Kodak", target: "RIM", type: "suit"},
  {source: "Nokia", target: "Qualcomm", type: "suit"}
];

var nodes = {};

// Compute the distinct nodes from the links.
links.forEach(function(link) {
  link.source = nodes[link.source] || (nodes[link.source] = {name: link.source});
  link.target = nodes[link.target] || (nodes[link.target] = {name: link.target});
});

var width = 960,
    height = 500;

var force = d3.layout.force()
    .nodes(d3.values(nodes))
    .links(links)
    .size([width, height])
    .linkDistance(60)
    .charge(-300)
    .on("tick", tick)
    .start();

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);

// Per-type markers, as they don't inherit styles.
svg.append("defs").selectAll("marker")
    .data(["suit", "licensing", "resolved"])
  .enter().append("marker")
    .attr("id", function(d) { return d; })
    .attr("viewBox", "0 -5 10 10")
    .attr("refX", 15)
    .attr("refY", -1.5)
    .attr("markerWidth", 6)
    .attr("markerHeight", 6)
    .attr("orient", "auto")
  .append("path")
    .attr("d", "M0,-5L10,0L0,5");

var path = svg.append("g").selectAll("path")
    .data(force.links())
  .enter().append("path")
    .attr("class", function(d) { return "link " + d.type; })
    .attr("marker-end", function(d) { return "url(#" + d.type + ")"; });

var circle = svg.append("g").selectAll("circle")
    .data(force.nodes())
  .enter().append("circle")
    .attr("r", 6)
    .call(force.drag);

var text = svg.append("g").selectAll("text")
    .data(force.nodes())
  .enter().append("text")
    .attr("x", 8)
    .attr("y", ".31em")
    .text(function(d) { return d.name; });

// Use elliptical arc path segments to doubly-encode directionality.
function tick() {
  path.attr("d", linkArc);
  circle.attr("transform", transform);
  text.attr("transform", transform);
}

function linkArc(d) {
  var dx = d.target.x - d.source.x,
      dy = d.target.y - d.source.y,
      dr = Math.sqrt(dx * dx + dy * dy);
  return "M" + d.source.x + "," + d.source.y + "A" + dr + "," + dr + " 0 0,1 " + d.target.x + "," + d.target.y;
}

function transform(d) {
  return "translate(" + d.x + "," + d.y + ")";
}

</script>

.链接{
填充:无;
行程:#666;
笔划宽度:1.5px;
}
#许可证{
填充:绿色;
}
.link.licensing{
笔画:绿色;
}
.link.resolved{
笔划数组:0,2 1;
}
圈{
填充:#ccc;
冲程:#333;
笔划宽度:1.5px;
}
正文{
字体:10px无衬线;
指针事件:无;
文本阴影:01px0#fff,1px0#fff,0-1px0#fff,-1px0#fff;
}
// http://blog.thomsonreuters.com/index.php/mobile-patent-suits-graphic-of-the-day/
变量链接=[
{来源:“微软”,目标:“亚马逊”,键入:“授权”},
{来源:“Microsoft”,目标:“HTC”,键入:“licensing”},
{来源:“三星”,目标:“苹果”,类型:“西装”},
{来源:“摩托罗拉”,目标:“苹果”,键入:“西服”},
{来源:“诺基亚”,目标:“苹果”,键入:“已解决”},
{来源:“HTC”,目标:“苹果”,键入:“suit”},
{来源:“柯达”,目标:“苹果”,键入:“西装”},
{来源:“Microsoft”,目标:“Barnes&Noble”,键入:“suit”},
{来源:“微软”,目标:“富士康”,键入:“西服”},
{来源:“甲骨文”,目标:“谷歌”,键入:“诉讼”},
{来源:“苹果”,目标:“HTC”,类型:“西装”},
{来源:“Microsoft”,目标:“Inventec”,键入:“suit”},
{来源:“三星”,目标:“柯达”,类型:“已解决”},
{来源:“LG”,目标:“柯达”,类型:“已解决”},
{来源:“RIM”,目标:“Kodak”,键入:“suit”},
{来源:“索尼”,目标:“LG”,类型:“西装”},
{来源:“柯达”,目标:“LG”,类型:“已解决”},
{来源:“苹果”,目标:“诺基亚”,键入:“已解决”},
{来源:“高通”,目标:“诺基亚”,键入:“已解决”},
{来源:“苹果”,目标:“摩托罗拉”,键入:“西装”},
{来源:“微软”,目标:“摩托罗拉”,键入:“诉讼”},
{来源:“摩托罗拉”,目标:“微软”,键入:“诉讼”},
{来源:“华为”,目标:“中兴”,类型:“西装”},
{来源:“爱立信”,目标:“中兴通讯”,键入:“诉讼”},
{来源:“柯达”,目标:“三星”,键入:“已解决”},
{来源:“苹果”,目标:“三星”,类型:“西装”},
{来源:“柯达”,目标:“RIM”,类型:“套装”},
{来源:“诺基亚”,目标:“高通”,键入:“西装”}
];
var节点={};
//从链接计算不同的节点。
links.forEach(函数(link){
link.source=节点[link.source]| |(节点[link.source]={name:link.source});
link.target=节点[link.target]| |(节点[link.target]={name:link.target});
});
可变宽度=960,
高度=500;
var-force=d3.layout.force()
.节点(d3.值(节点))
.链接(links)
.尺寸([宽度、高度])
.linkDistance(60)
。收费(-300)
.on(“滴答”,滴答)
.start();
var svg=d3.选择(“正文”).追加(“svg”)
.attr(“宽度”,宽度)
.attr(“高度”,高度);
//每类型标记,因为它们不继承样式。
svg.append(“defs”).selectAll(“marker”)
.数据([“诉讼”、“许可”、“已解决”])
.enter().append(“标记”)
.attr(“id”,函数(d){return d;})
.attr(“视图框”,“0-5 10”)
.attr(“参考文献”,第15页)
.attr(“参考文献”,-1.5)
.attr(“markerWidth”,6)
.attr(“markerHeight”,6)
.attr(“方向”、“自动”)
.append(“路径”)
.attr(“d”,“M0,-5L10,0L0,5”);
var path=svg.append(“g”).selectAll(“path”)
.data(force.links())
.enter().append(“路径”)
.attr(“类”,函数(d){return“link”+d.type;})
.attr(“marker end”,函数(d){return”url(#“+d.type+”);});
var circle=svg.append(“g”).selectAll(“circle”)
.data(force.nodes())
.enter().append(“圆”)
.attr(“r”,6)
.呼叫(强制拖动);
var text=svg.append(“g”).selectAll(“text”)
.data(force.nodes())
.enter().append(“文本”)
.attr(“x”,8)
.attr(“y”,“.31em”)
.text(函数(d){返回d.name;});
//使用椭圆弧路径段对方向性进行双重编码。
函数tick(){
路径属性(“d”,链接弧);
circle.attr(“transform”,transform);
attr(“transform”,transform);
}
功能链接弧(d){
变量dx=d.target.x-d.source.x,
dy=d.target.y-d.source.y,
dr=Math.sqrt(dx*dx+dy*dy);
返回“M”+d.source.x+”、“+d.source.y+”A“+dr+”、“+dr+”0,1“+d.target.x+”、“+d.target.y”;
}
函数变换(d){
返回“translate”(“+d.x+”,“+d.y+”);
}

当分配
标记结束
属性时,只需检查传递的数据的类型是否为许可,如果是,则返回
未定义

.attr("marker-end", function(d) {
  if (d.type == 'licensing') return undefined;
  return "url(#" + d.type + ")"; 
});
.attr("marker-end", function(d) {
  if (d.type == 'licensing') return undefined;
  return "url(#" + d.type + ")"; 
});