{
const textLabel = fc.layoutTextLabel()
.padding(labelPadding)
.value((d) => d.state);
const strategy = fc.layoutRemoveOverlaps();
const fontSettings = (selection) => {
selection
.attr('font-size', `${24}px`)
.attr('font-weight', 'bold')
.attr('font-family', `Roboto`);
};
const labels = fc.layoutLabel(strategy)
.size((d, i, g) => {
const selection = d3.select(g[i]);
const textSize = selection
.select('text')
.call(fontSettings)
.node()
.getBBox();
return [
textSize.width + labelPadding * 2,
textSize.height + labelPadding * 2
];
})
.position((d, i, g) => {
const selection = d3.select(g[i]);
selection
.select('text')
.call(fontSettings)
.node()
.getBBox();
return [
getX(d),
getY(d)
];
})
.component(textLabel);
const filteredData = data.filter((d) => d.population > populationThreshold);
bubbles.datum(filteredData).call(labels);
d3.selectAll('g.label rect').attr('fill', 'rgba(0,0,0,0.2)');
return "Data Labels with filter strategy";
}