You can do this by placing an if/else statement in an anonymous function where you would output the text string. Within that if/else you can satisfy any condition that you want and create a function that parses your value. Here is an example:
var w = 30, h = 300;
var data = [
{'point':1, 'value':100.005},
{'point':2, 'value':20.010},
{'point':3, 'value':1000},
{'point':4, 'value':5000.099},
{'point':5, 'value':6000.934},
{'point':6, 'value':9000.888},
{'point':7, 'value':500.22},
{'point':8, 'value':5.123},
{'point':9, 'value':50.022},
{'point':10, 'value':7000.999}
];
var chart = d3.select("body").append("svg")
.attr('class', 'chart')
.attr("width", w * data.length - 1)
.attr("height", h);
chart.selectAll('text')
.data(data)
.enter().append('text')
.attr('x', function(d, i) { return x(i); })
.attr('y', function(d) { return h - y(d.value); })
.attr('dx', '0.75em')
.attr('dy', '-0.3em')
.attr('text-anchor', 'start')
.text(function(d) {
if(d.value > 5000) {
// Define your formatting function to return SI units
var si = d3.format('s');
return String(si(d.value));
} else {
// Otherwise round to the nearest integer
return String(d3.round(d.value, 0));
}
});
Hope that helps.