0

https://jsfiddle.net/ejy7n9wa/

The above is a working jsfiddle. Visit it in chrome, then visit in firefox. Works in firefox, doesn't work in Google Chrome. Can someone help me get it to work on chrome?

Relevant code:

var link = svg.selectAll("line.link")
        .data(json.links)
        .enter().append("svg:line")
        .attr("class", "link")
        .attr("id", function(d, i){
            return "linkId_" + i;
        })
        .style('stroke', '#333')
        .attr("x1", function(d) {
            return d.source.x;
        })
        .attr("y1", function(d) {
            return d.source.y;
        })
        .attr("x2", function(d) {
            return d.target.x;
        })
        .attr("y2", function(d) {
            return d.target.y;
        });

    var labelText = svg.selectAll(".labelText")
        .data(force.links())
        .enter().append("text")
        .attr("class","labelText")
        .attr("dx",20)
        .attr("dy",0)
        .style("fill","red")
        .append("textPath")
        .attr("xlink:href",function(d,i) { return "#linkId_" + i;})
        .text(function(d,i) { return "text for link " + i;});
Mike Johnson
  • 37
  • 1
  • 5
  • take a look at, https://stackoverflow.com/questions/57424958/svg-text-does-not-render-in-chrome-or-safari. you may need to replace line with path as setting textPath to non-path shapes isn't supported in all browsers yet. – learner Aug 23 '20 at 03:52
  • how might I do that? I am new to d3/svg – Mike Johnson Aug 23 '20 at 18:47

0 Answers0