Skip to content

Instantly share code, notes, and snippets.

@slashk
Created February 14, 2014 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slashk/9001367 to your computer and use it in GitHub Desktop.
Save slashk/9001367 to your computer and use it in GitHub Desktop.
John's Color renderlet
var colorRenderlet = function (_chart) {
function setAttr(selection, keyName) {
selection.style("fill", function (d) {
if (d[keyName] == "Apples")
return "red";
else if (d[keyName] == "Kiwis")
return "green";
else if (d[keyName] == "Lemons")
return "yellow";
});
}
// set the fill attribute for the bars
setStyle(_chart
.selectAll("g.stack")
.selectAll("rect.bar")
, "layer"
);
// set the fill attribute for the legend
setStyle(_chart
.selectAll("g.dc-legend-item")
.selectAll("rect")
, "name"
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment