I am trying to make some changes to a path defined using D3 programmatically. The change I want to make is pretty simple, changing the opacity of the path. I have a problem until the path itself changes, the end marker does not do this, and I'm not quite sure how to do this.
The marker is defined as follows:
// define arrow markers for graph links svg.append('svg:defs').append('svg:marker') .attr('id', 'end-arrow') .attr('viewBox', '0 -5 10 10') .attr('refX', 6) .attr('markerWidth', 3) .attr('markerHeight', 3) .attr('orient', 'auto') .append('svg:path') .attr('d', 'M0,-5L10,0L0,5') .attr('fill', '#CCCCCC');
Way:
// Create the links between the nodes var links = svg.append("g") .selectAll(".link") .data(data.links) .enter() .append("path") .attr("class", "link") .attr("d", sankey.link()) .style('marker-end', "url(#end-arrow)") .style("stroke-width", function (d) { return Math.max(1, d.dy); }) .sort(function (a, b) { return b.dy - a.dy; });
The code I use to change paths that does not update tokens is:
d3.selectAll("path.link") .filter(function (link) { // Find all the links that come to/from this node if (self.sourceLinksMatch(self, link, node)) { return true; } if (self.targetLinksMatch(self, link, node)) { return true; } return false; }) .transition() .style("stroke-opacity", 0.5);
Can anyone suggest what I might need to change to change the style of the marker end?
thanks