Created
February 14, 2014 13:55
-
-
Save slashk/9001367 to your computer and use it in GitHub Desktop.
John's Color renderlet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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