JS D3 textPath isn't displayed

2020-03-27 07:50发布

i have the code below and wonder, why the textpath isn't displayed? Can anyone help?

var areas = svg.append("g").selectAll("path")
    .data(chord.groups)
    .enter().append("path")
    .style("fill", function(d) { return fill(d.index); })
    .style("stroke", function(d) { return fill(d.index); })
    .attr("class", "bar")
    .attr("id", function(d, i) { return "group" + i; })
    .attr("d", d3.svg.arc().innerRadius(innerRadius).outerRadius(outerRadius))
    .on("mouseover", fade(.1))
    .on("mouseout", fade(1));

svg.selectAll(".bar").append("text")
    .style("font-size", "10px")
    .attr("fill", "black")
.append("textPath")
    .attr("x", 8)
    .attr("dy", ".35em")
    .style("fill", "#ff00ff")
    .attr("xlink:href", function(d, i) { return "#group" + i; })
    .text("Textexample");

Thank you very much! Benjamin

0条回答
登录 后发表回答