Question: I would like to set a specific color on the circle of bubble chart in terms of a variable. I can change all the bubble in red for example but not each bubble. My condition is an attribute of d and it define by the content of my JSON.

```
node.append("circle")
        .attr("r", function(d) { return d.size; })
        .style("fill", "red"); // all my bubble are red but the condition doesn't works
        /* 
        if (condition) {
          .style("fill", "red");
        } else {
          .style("fill","green");
        }
        */

```

This is the Plunker project : <https://plnkr.co/edit/07RZFQoBrBz2xWxmiCl0?p=preview>
Thanks.

Answer: 
`reduce` over the colspan info.

```
var th = document.querySelectorAll('table thead tr:first-child th');

var cols = [].reduce.call(th, function (p, c) {
  var colspan = c.getAttribute('colspan') || 1;
  return p + +colspan;
}, 0);

```

[DEMO](https://jsfiddle.net/toahb3a3/3/)
To get total colspan count - Try this:

```
$( document ).ready(function() {
  var colspan = 0;
  $( "th" ).each(function( index ) {
   if(typeof $(this).attr('colspan') != 'undefined') {
      colspan = colspan + parseInt($(this).attr('colspan'));
    }
    console.log(colspan)
  });
});

```