The 'd3-circle-text' plug-in works great on a static circle-pack (many thanks to musically-ut for contributing https://github.com/musically-ut/d3-circle-text). However, on a zoomable circle-pack, labels fly about the place (in the fiddle, they stay static not repositioning on zoom).
Is it possible to get the circle-text to zoom with the circles? (If the plug-in isn't zoomable, that's ok. I'll try another labelling approach.)
Here's the code section I'm working on:
////////////Circle text
var circleText = d3.circleText()
.radius(function(d) {
return d.r - 5;
})
.value(function(d) {
return d.key; //Get lables
})
.method('align')
.spacing('exact')
.precision(0.1)
.fontSize('100%');
var gTexts = svg.selectAll('g.label')
.data(pack.nodes) //Returns names
.enter()
.append('g')
.classed('label', true)
.attr('transform', function(d) {
return 'translate(' + d.x + ',' + d.y + ')';
});
/*.attr("x", function (d) { return d.x; })
.attr("y", function (d) { return d.y; }); */ An attempt - not working
/*.attr("cx", function (d) { return d.x; })
.attr("cy", function (d) { return d.y; }); */ An attempt - not working
//Only put on 'parent' circles
gTexts.filter(function(d) {
return !!d.children;
})
.call(circleText)
//.style('fill', 'white');
Here's a full fiddle: http://jsfiddle.net/cajmcmahon/9a5xaovv/1/
Thanks for any help.