You can change the json file for your data and customize the d3 code to indicate what color each individual bubble fills.
Below is my data, and you can see that I indicate what color fill the bubbles.
{ "name": "sentiment", "children": [ { "name": "positive", "children": [ { "name": "iphone", "size": 2000, "color": "green" } ] } ] }
Then I add the color attribute that I pointed to the node object so that it can later be retrieved in the d3 function.
function recurse(name, node) { if (node.children) node.children.forEach(function(child) { recurse(node.name, child); }); else classes.push({ packageName: name, className: node.name, value: node.size, color: node.color }); }
Then find the function responsible for coloring the bubbles and edit the fill function.
node.append("circle") .attr("r", function(d) { return dr; }) .style("fill", function(d) { return d.color; });
My code is being edited from the code given at http://bl.ocks.org/mbostock/4063269
source share