The code I have is:
var level = function (d) { if (value(d) > median + stdev) { return 1; } else if (value(d) > median) { return 2
This solution is nicer, but I would not recommend using it in production as it is kind of confusing:
4 - [median + stdev, median, median - stdev].filter(function(e, i, a) { return value(d) > e; }).length