perhaps I am misunderstanding, but couldn't you just transform the result as you suggested after applying the scale function? ie:

function roundScale(origVal) { return Math.round(x.scale(origVal)/25) * 25;}

then use that value to set attributes:

.attr("x", function(d) { return roundScale(d.value); }


Are you looking for the nice function?

x.scale = d3.time.scale().domain(x.extent)
            .range([0, dimensions.graph.width]).nice();


The correct answer is interpolateRound, from the docs

Returns an interpolator between the two numbers a and b; the interpolator is similar to interpolateNumber, except it will round the resulting value to the nearest integer.

var xScale = d3.scaleLinear()
    .domain([0, 100])
    .range([0, width])
    .interpolate(d3.interpolateRound); // <-- round interpolation

Related Query