私はこの作業コードを持っています。d3 部分は基本的に次のとおりです。
var bar = chart.append("div").attr("class", "chart")
.selectAll('div')
.data(scope.data.sort().reverse()).enter().append("div")
.transition().ease("elastic")
.style("width", function(d) { return (d[0]/sum)*attrs.chartWidth + "px"; })//This is where I base the width as a precentage from the sum and calculate it according to the chart-width attribute
.style("background-color",function(){i++;if (i<=colors.length-1){return colors[i-1]} else {return colors[(i-1)%colors.length]}}).text(function(d) { return d[1] ; })
しかし、連鎖させようとするとappend("span")
、テキストは親divではなくスパンになります。テキストが消えるだけで、開発コンソールにはスパンとテキストの両方の手がかりが表示されません。またinsert("span")
、.text
for を試してみました.html(function(d){return "<span>"+d[1]+"</span>"}
どちらも機能しません。
手がかりはありますか?ありがとう!