score:1

Accepted answer

You have to save the group with the class parte.

And then append to this selection the paths you need.

var outerPath = svg.selectAll(".outlineArc")
  .data(pie(data))
  .enter().append("g")
  .attr("class", "parte");

outerPath.append("path")
  .attr("fill", calcularColor)
  .attr("stroke", "grey")
  .attr("class", "outlineArc")
  .attr("d", outlineArc);

outerPath.append("path")
  .attr("fill", "#074590")
  .attr("class", "solidArc")
  .attr("stroke", "grey")
  .attr("d", arc);

var data = [
  {
    "id": 251,
    "proyecto_id": 6,
    "area_id": 1,
    "nombre": "Tarea 1",
    "fecha_inicio": {
      "date": "2018-07-10 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "fecha_termino_original": {
      "date": "2018-07-17 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "fecha_termino": {
      "date": "2018-07-17 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "atraso": 0,
    "avance": 35,
    "weight": 1,
    "width": 1
  },
  {
    "id": 252,
    "proyecto_id": 6,
    "area_id": 1,
    "nombre": "Tarea 2",
    "fecha_inicio": {
      "date": "2018-07-09 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "fecha_termino_original": {
      "date": "2018-07-16 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "fecha_termino": {
      "date": "2018-07-16 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "atraso": 0,
    "avance": 70,
    "weight": 1,
    "width": 1
  },
  {
    "id": 253,
    "proyecto_id": 6,
    "area_id": 5,
    "nombre": "Tarea 3",
    "fecha_inicio": {
      "date": "2018-07-09 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "fecha_termino_original": {
      "date": "2018-07-13 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "fecha_termino": {
      "date": "2018-07-13 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "atraso": 0,
    "avance": 35,
    "weight": 1,
    "width": 1
  },
  {
    "id": 254,
    "proyecto_id": 6,
    "area_id": 6,
    "nombre": "Tarea 4",
    "fecha_inicio": {
      "date": "2018-07-23 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "fecha_termino_original": {
      "date": "2018-07-27 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "fecha_termino": {
      "date": "2018-07-27 00:00:00.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "atraso": 0,
    "avance": 95,
    "weight": 1,
    "width": 1
  }
]

///////////////////////////////

var width = 500,
    height = 500,
    radius = Math.min(width, height) / 2,
    innerRadius = 0 * radius; //radio circulo interno
    
var pie = d3.layout.pie()
  .sort(null)
  .value(function(d) {
    return d.width;
  });
  
var arc = d3.svg.arc()
  .innerRadius(innerRadius)
  .outerRadius(function(d) {
    return (radius - innerRadius) * (d.data.avance / 100.0) + innerRadius;
  });

var outlineArc = d3.svg.arc()
  .innerRadius(innerRadius)
  .outerRadius(radius);

var svg = d3.select("#grafico").append("svg")
  //.attr("width", width)
  //.attr("height", height)
  .attr('viewBox', "0 0 " + 500 + " " + 500)
  .style("border", '1px solid grey')
  .append("g")
  .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");


try {
  data.forEach(function(d) {
    d.id = d.id;
    d.proyecto_id = d.proyecto_id;
    d.area_id = d.area_id;
    d.nombre = d.nombre;
    d.fecha_inicio.date = d.fecha_inicio.date;
    d.fecha_termino_original.date = d.fecha_termino_original.date;
    d.fecha_termino.date = d.fecha_termino.date;
    d.atraso = d.atraso;
    d.avance = d.avance;
    d.weight = 1;
    d.width = +d.weight;
  });
} catch (TypeError) {
  console.log("Error");
}
var j = 0;
var outerPath = svg.selectAll(".outlineArc")
  .data(pie(data))
  .enter().append("g")
  .attr("class", "parte");

outerPath.append("path")
  .attr("fill", calcularColor)
  .attr("stroke", "grey")
  .attr("class", "outlineArc")
  .attr("d", outlineArc);
  
outerPath.append("path")
  .attr("fill", "#074590")
  .attr("class", "solidArc")
  .attr("stroke", "grey")
  .attr("d", arc);

// calculate the weighted mean avance
var avance =
  data.reduce(function(a, b) {
    return a + (b.avance * b.weight);
  }, 0) /
  data.reduce(function(a, b) {
    return a + b.weight;
  }, 0);
  
  function calcularColor(d) {
    var hoy = new Date();
    var fechaActividad = new Date(d.data.fecha_termino.date);
    var diferencia = daysBetween(hoy, fechaActividad);
    //console.log(diferencia);
    if (diferencia < 0) {
        return "#cc0000"; //rojo    
    }
    if (diferencia < 7 && diferencia >= 0) {
        return "#ff9900"; //naranjo    
    }
    if (diferencia >= 7) {
        return "#009900"; //verde
    }
}

function treatAsUTC(date) {
    var result = new Date(date);
    result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
    return result;
}

function daysBetween(startDate, endDate) {
    var millisecondsPerDay = 24 * 60 * 60 * 1000;
    return (treatAsUTC(endDate) - treatAsUTC(startDate)) / millisecondsPerDay;
}
.outlineArc:hover, .solidArc:hover{
  fill: cyan;
}

.solidArc, .outlineArc {
    -moz-transition: all 0.3s;
    -o-transition: all 0.3s;
    -webkit-transition: all 0.3s;
    transition: all 0.3s;    
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.3.13/d3.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row" id="graficoBotones">
  <div id="zoom" class="col-6">
    <div class="small">
      <div id="grafico"></div>
    </div>
  </div>
</div>


Related Query

More Query from same tag