Accepted answer

After several comments I finally have an idea of how you are filtering the node selection.

In the following demo, the circles have 4 different colours:

var colours = ["blue", "red", "green", "yellow"];

node.attr("fill", (d, i) => colours[i%4]);

So, when you click the button, we simply filter the nodes with "red" colour and increase their r property, making the collide radius increase, using each:

node.filter(function() {
    return"fill") === "red"
}).each(d => d.r = 40);

If you want use data as a getter, you can do it with a forEach:

node.filter(function() {
    return"fill") === "red"
}).data().forEach(d => d.r = 40);

Which has the same result.

Here is a demo, all red nodes will push away the other nodes after the click, with a collide radius of 40:

var svg ="svg");

var colours = ["blue", "red", "green", "yellow"];

var data = d3.range(30).map(d => ({
    r: 6

var simulation = d3.forceSimulation(data)
    .force("x", d3.forceX(150).strength(0.05))
    .force("y", d3.forceY(75).strength(0.05))
    .force("collide", d3.forceCollide(function(d) {
        return d.r + 1;

var node = svg.selectAll(".circles")
    .attr("r", d => d.r)
    .attr("fill", (d, i) => colours[i%4]);"button").on("click", function(d) {
		 return"fill") === "red"
		}).each(d=>d.r = 40);

    .on("tick", d => {
        node.attr("cx", d => d.x).attr("cy", d => d.y);
<script src=""></script>
<button>Click me</button>

Related Query

More Query from same tag