.colors function in barChart dc.js with only two options
问题 I want to create a color function which shows red when the value is negative and green otherwise in a barChart. Here is what I've come up with so far : var colorChoice = d3.scale.ordinal().domain(["positive","negative"]) .range(["#00FF00","#FF0000"]); hitsPerDaybarChart .colors(function(d) {return(colorChoice((d.hits>0) ? "positive":"negative"));}) But I get the following error message : TypeError: Object function (d) {return(colorChoice((d.pnl>0) ? "positive":"negative"));} has no method