Hello,
I am trying to create a bubblechart(?), I can get the shapes drawn and all that but for whatever reason the text isn’ t showing up. This is the code:
{
function circlePath(cx, cy, r, ){
return 'M '+cx+' '+cy+' m -'+r+', 0 a '+r+','+r+' 0 1,0 '+(r*2)+',0 a '+r+','+r+' 0 1,0 -'+(r*2)+',0';
};
const svg = d3.select(DOM.svg(400, 200));
const summaries = data_circles.map(location => ([location.num_locs, location.total, location.num_samps, location.ave_dense, location.location, 25]));
const bubbles = svg.selectAll("g").data(summaries).enter()
.append("g");
bubbles.append("path")
.attr('d', function(d,i) {return circlePath(100+(i*100), 100, 50)})
.attr("fill", "blue")
.attr("id", d => (d.pathid = DOM.uid(d[4]).id));
// bubbles.append("defs").append("path")
// .attr('d', function(d,i) {return circlePath(100+(i*100), 100, 48)})
// .attr("id", d => (d.pathid = DOM.uid(d[4]).id));
bubbles.append("text")
.attr("font-size", "20px")
.attr("font-weght", "bold")
.attr("font-family", "sans")
.attr("color", "black")
.attr("dx", "0")
.attr("dy", "0")
.append("textPath")
.attr("xlink:xlink:href", d => '#' + d.pathid)
.text("name");
return svg.node();
}
It is returning this value:
<svg viewBox="0,0,400,200" width="400" height="200">
<g>
<path d="M 100 100 m -50, 0 a 50,50 0 1,0 100,0 a 50,50 0 1,0 -100,0" fill="blue" id="O-Aare-7"></path>
<text font-size="20px" font-weght="bold" font-family="sans" color="black" dx="0" dy="0">
<textPath xlink:href="#O-Aare-7">name</textPath>
</text>
</g>
<g>
<path d="M 200 100 m -50, 0 a 50,50 0 1,0 100,0 a 50,50 0 1,0 -100,0" fill="blue" id="O-Rhein-8"></path>
<text font-size="20px" font-weght="bold" font-family="sans" color="black" dx="0" dy="0">
<textPath xlink:href="#O-Rhein-8">name</textPath>
</text>
</g>
</svg>
Like I said the circles show up but not the text. There are 136 bubbles(?)
So where I am going wrong?