Accepted answer

You could do something like this.

1) Work out the average of your data

var average = d3.mean({return i[1]})));

2) Use the average when setting the color

if (d.value > average)
  return "#49B5A6"
  return "#F86A52"


You can do it this way first calculate the average:

var average = d3.mean( {
  return i[1]

Then use this to color the nodes(

  data: {
    xs: {
      Mike: 'ibm_x',
      Susan: 'microsoft_x',
      Glen: 'tcs',
      Harris: 'sun',
      Tom: 'infosys',
      Lear: 'oracle',
      Leon: 'ibm_y',
      Neo: 'ibm_z',
      Suraj: 'ibm_a',
      Nayan: 'ibm_b',
      Jhagan: 'ibm_c'
    //color the nodes
    color: function(color, d) {
      if (d.value > average) {
        return "#F86A52"
      } else {
        return "#49B5A6"

You don't need the code below:

d3.selectAll(".c3-circle").style("fill", function(d, i) {

     abc = (d.x+d.value);

     function numberSum(N) {var total = 0;
for(var i = 1; i <= N; i++){
  total += i;
return total;}return i % 2 ? "#F86A52" : "#49B5A6";});

Working code here.

Hope this helps!

Related Query