Accepted answer

When you do this:"circle")

You are selecting only the first circle (if any) in the page. According to the API, select...

Selects the first element that matches the specified selector string. (emphasis mine)

That being said, you need selectAll here. But that alone will not fix the problem: you have to rebind the data. Since I don't know your data structure, the default method binds by index.

All together, it should be:


As those circles have a class named dot, you can avoid selecting other circles using:


Regarding the line and the area, do the same: bind the data first and then change their d attribute:".area")
    .attr("d", area);".line")
    .attr("d", valueline);

Also, since you are rebinding the data, you'll have to change this:

var svg ="body").transition();

Because svg.selectAll will be a transition selection.That being said, set the transition to each individual selection after rebinding the data, removing it from the svg selection.

Related Query

More Query from same tag