In the example, http://mbostock.github.com/d3/ex/bubble.html:

In line 27:
.style("fill", function(d) { return fill(d.packageName); });
Where is fill() defined? I didn’t find it in d3.js either. And even if the package name is not a color, some random color is being assigned. How so?
Take a look at the very top of the snippet you linked:
That third line is where
fillis being defined. You can find the doc forcategory20chere:https://github.com/mbostock/d3/wiki/Ordinal-Scales#wiki-category20