score:2

Accepted answer

in order to have the same behavior as the original code, you need to return a function (that itself returns a function when called) from runnumber. this should work (untested):

function runnumber(start, end, decimal) {
    return function() {
        var n = d3.interpolatenumber(start, end);
        return function(t) {
            d3.select(this).text(n(t).tofixed(decimal) + '%');
        };
    };
}

Related Query

More Query from same tag