Reputation: 2977
I started from a sample Map app at: http://bl.ocks.org/d3noob/raw/5193723/
I want to place a custom pie chart, as shown in the fig below. I created one by adding the code snippet just after the creation of circles is done.
Pie-chart Snippet:
var r=10;
var p = Math.PI*2;
var arc = d3.svg.arc()
.innerRadius(r-3)
.outerRadius(r)
.startAngle(0)
.endAngle(p* d.value1);
var arc2 = d3.svg.arc()
.innerRadius(r-7)
.outerRadius(r-4)
.startAngle(0)
.endAngle(p* d.value2);
g.append("path")
.attr("d", arc)
.attr("fill", "red")
.attr("transform", "translate(400,500)");
g.append("path")
.attr("d", arc2)
.attr("fill", "orange")
.attr("transform", "translate(400,500)");
It comes out nicely as shown in the pic below near Thailand:
Problem
Upvotes: 0
Views: 250
Reputation: 25157
The code that runs when zoom takes place
g.selectAll("path")
.attr("d", path.projection(projection));
is selecting all paths and modifying their "d"
attribute. Since it's "generically" just looking for paths
s, then it's also grabbing the donut paths you created and modifying them (probably setting them to empty strings or NaN
s).
You can fix this either by taking the donuts out of the same g
of the geo paths, so that they don't get selected. OR, you can make your "path"
selector more specific, by adding some class (e.g. "geo"
) to all the geo paths and using that class whenever you select them (e.g. g.selectAll("path.geo")
).
Upvotes: 1