Hey all,
So, I think there should be a pretty succinct way to wrap a function around a scale to handle null/undefined values. Currently, i believe scales will return treat these values as 0. But, I would like a custom color in my case to be output. Additionally, I would like this function to retain all of the methods of the scale it is modifying.
For instance
var scale = d3.scale.linear().domain([0,10]).range(["red","blue"])
to give a custom color to the null/undefined values I could do something like:
function newScale(d){
var nullColor = "black"
return (d === undefined || d === null)?nullColor:scale(d)}
but then trying to access the scales methods would work
newScale.domain()
I could inherit the methods using d3.rebind, but then I would need a list of methods. I would like this to be general for any type of scale (linear,log,whatever).
Any ideas? This seems doable, but i can't work it out.
Thanks in advance.
Chris