Afraid I'm making a simple error in in how I convert this JavaScript to CoffeeScript within a class
In this original example of a world map we have a function :
var quantize = d3.scale.quantize()
.domain([0, .15])
.range(d3.range(9).map(function(i) { return "q" + i + "-9"; }));
This is then called when the map is rendered:
.attr("class", function(d) { return quantize(rateById.get(d.id)); })
And we are left with something like class="q8-9
which is what we want.
Converting this to CoffeeScript I have:
quantize: ->
d3.scale.quantize()
.domain([0, .15])
.range(d3.range(9).map((i) -> "q" + i + "-9" ))
Which I then call like this:
.attr("class", (d) => @quantize(rateById.get(d.id)) )
However this does't return a value, rather it returns the scale function, leaving me with this:
class="function scale(x) { return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))]; }"
I'm sure I'm doing something very simple wrong but can't figure it out. Can you help?