Accepted answer

There are several ways for achieving this. Since both circles and texts use the same dataset, my solution uses filter.

First, let's name the variables for the texts and circles:

var circles = svg.selectAll("circle")

var texts = svg.selectAll("text")

Then, inside the circles mouseover function, we filter the texts that have the same colour attribute:

.on("mouseover", function(d){"stroke", "black").style("stroke-width", 2);
    var tempTexts = texts.filter(function(e){
        return e.colour === d.colour
    });"opacity", 1);

This is your updated fiddle:

Related Query