D3.js 在d3的移动套件示例上显示每个节点的不同图像

D3.js 在d3的移动套件示例上显示每个节点的不同图像,d3.js,D3.js,如何显示不同图像的每个节点。我展示了github上d3的一个示例。但是在这里面只有一个链接 如何为每个节点显示不同的图像。有解决办法吗 这是我的 函数displayNote(){ var chkStatus1=document.getElementById(“door2”); 如果(chkStatus1.选中) { 返回d.rel; } 其他的 { 返回“----” 在这个例子中,我想要什么?@Jubobs。 var nodes = {}; // Compute the dist

如何显示不同图像的每个节点。我展示了github上d3的一个示例。但是在这里面只有一个链接

如何为每个节点显示不同的图像。有解决办法吗

这是我的

函数displayNote(){ var chkStatus1=document.getElementById(“door2”); 如果(chkStatus1.选中) { 返回d.rel; } 其他的 { 返回“----”


在这个例子中,我想要什么?@Jubobs。
    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 = 900,
    height = 900;

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



var svg = d3.select("#d3Graph").append("svg")
    .attr("width", width)
    .attr("height", height).call(zoom);


// 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", 3)
    .call(force.drag);

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

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

var path_label = svg.append("svg:g").selectAll(".path_label")
.data(force.links())
.enter().append("svg:text")
.attr("class", "path_label")
.append("svg:textPath")
  .attr("startOffset", "50%")
  .attr("text-anchor", "middle")
  .attr("xlink:href", function(d) { return "#" + d.source.index + "_" + d.target.index; })
  .style("fill", "#000")//edge color 
  .style("font-size","10px")
  .style("font-family", "Serif")

  .text(function displayNote(d){ return "";// d.rel;
      });

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

  edgeText.attr("d", function(d) {
         var dx = d.target.x - d.source.x,
             dy = d.target.y - d.source.y,
             dr = 0;//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 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 + ")";
}