edit text not found in the html where d3js is being used

前端 未结 1 1885
Happy的楠姐
Happy的楠姐 2021-01-27 09:25

in this codepen 1: https://codepen.io/Siddharth11/pen/LVQmjN

I understand d3js is being used here.

When I use the browser to check ,i see all the class.Plz se

1条回答
  •  执念已碎
    2021-01-27 09:37

    The text attribute changes the innerHTML of the . Right now it is color[i]. Change it to change the labels. I suggest you to read the documentation of d3. https://github.com/d3/d3/wiki

     text.enter()
        .append('text')
        .attr('dy', '0.35em')
        .style("opacity", 0)
        .style('fill', (d, i) => colors[i])
        .text((d, i) => colors[i]) //<-- Change here
        .attr('transform', d => {
          // calculate outerArc centroid for 'this' slice
          let pos = outerArc.centroid(d)
          // define left and right alignment of text labels                             
          pos[0] = radius * (midAngle(d) < Math.PI ? 1 : -1)
          return `translate(${pos})`
        })
        .style('text-anchor', d => midAngle(d) < Math.PI ? "start" : "end")
        .transition()
        .delay((d, i) => arcAnimDur + (i * secIndividualdelay))
        .duration(secDur)
        .style('opacity', 1)
    

    0 讨论(0)
提交回复
热议问题