score:2

Accepted answer

The problem is not that the datum (d) attribute isn't being passed: it is. The problem here is just the structure of the data that the link generator is expecting.

If you look at the API, you'll see that the link generator, by default, expects a data structure like this:

{
  source: foo,
  target: baz
}

By the way, you can change these properties by using link.source() and link.target().

So, if we change your data structure, the console will work:

var svg = d3.select("svg");

var myEdges = [{
  source: { in: "934e3e11-3f9b-11e9-b2b9-c54f58764873",
    out: "936807a1-3f9b-11e9-b2b9-c54f58764873"
  },
  target: { in: "934e3e11-3f9b-11e9-b2b9-c54f58764873",
    out: "936807a1-3f9b-11e9-b2b9-c54f58764873"
  }
}]

svg.selectAll('path:not([elementType=temp-path])').data(myEdges)
  .enter().append('path')
  .attr("fill", "none")
  .attr("stroke", "blue")
  .style("stroke-width", "2px")
  .attr('dummy', function(d) {
    console.log("dummy here: " + d);
    return d;
  })
  .attr('d', d3.linkVertical()
    .x(function(d) {
      console.log(d);
      return d.in;
    })
    .y(function(d) {
      return d.out;
    }));
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
<svg></svg>

Finally, these other answers may help you to understand the data structure required by the link generator: https://stackoverflow.com/a/44760465/5768908 and https://stackoverflow.com/a/51424331/5768908


Related Query

More Query from same tag