Joins, Drill 3

Write the function updateEvenCircles that will take a selection of elements, and update the data bound to circles with even keys to the values in the variable newData. Each circle is bound to an object with the shape {key: ..., value: ...}, and the join selection corresponding to the key field of each value in the array.

<body>
  <svg id="svg">
  </svg>
  <script>
    var elements = d3.selectAll("#svg")
        .data([{ key: "4", value: 6},
               { key: "3", value: 12},
               { key: "2", value: 5},
               { key: "1", value: 10}],
              function(d) { return d.key; })
        .enter().append("circle");
    data = [{ key: "2", value: 100},
            { key: "4", value: 200}];
    updateEvenCircles(elements, data); // write this function
  </script>
</body>

Try it

Editor
HTML Output
Messages

  
DOM