Here is a basic start to what you're trying to achieve. You need to start by adding a click function to your circle.

circle.on('click', function(d){
    //grabs all the circles from your array
    var allCircles = circle[0]

    //Used to cycle through to see if any of them are classed with the 'selected' class'
    for (var i=0; i<allCircles.length; i++){[i]).classed('selected', false)[i]).attr('style', 'fill: rgb(0,128,0);')

    //Set the circle you clicked on to have no inline style and classed to 'selected''style', '')'selected', true)

I've updated the fiddle so you can see. You can edit the CSS however you need. Currently, it just fills the circle with a blue fill, but you can use CSS similar to the example you posted.


When you click the bubble, the g-selected class is added to the nodes. That changes the css that applies from

.g-node .g-democrat {
    fill: #c5d7ea;
.g-node .g-republican {
    fill: #f9caca;


.g-node.g-selected .g-democrat {
    fill: #99c0e5;
    stroke: #6081a3;
    stroke-width: 1.5px;
.g-node.g-selected .g-republican {
    fill: #fda4a7;
    stroke: #af5e61;
    stroke-width: 1.5px;

Adding a class to a clicked element is pretty straightforward. The class is added using the selection.classed method.

node.classed("g-selected", function(d) { return d === topic; });

If you are looking at the source, look at the updateActiveTopic function.

The code in your fiddle is quite a bit simpler than the example you linked. I would change the part where you create the circle elements so that it uses css, rather than inline style, i.e.

circle {
    fill: green;

instead of

 .style("fill", function (d, i) {
      return "green";

Now, you'll add a click handler to the circles:

circle.on("click", function(d) {
        // remove selected class from all circles that have it
        circle.classed('selected', false);

        //add the selected class to the element that was clicked'selected', true)

and a style to highlight the circle when it is selected

circle.selected {
    fill: blue;
    stroke: black;
    stroke-width: 1.5px;

See the fiddle for the complete example.