I am trying to learn D3 and i am having a hard time to understand the anonymous functions.
In the following example, there is at the bottom function(f) and it returns returns the variable "interpolate" with the parameter f (which i think is itself akward, since "interpolate" is not a function, but a variable).
But what is the meaning of F? I do not see how or where it is used in the function of "interpolate". If i delete F and just pass (), my animation breaks.
Thanks! :)
svg.append('path')
.attr('class', 'line')
.attr('d', line(lineData))
.transition()
.duration(3000)
.attrTween('d', pathTween);
function pathTween() {
var interpolate = d3.scale.quantile()
.domain([0,1])
.range(d3.range(0, 7));
return function(f) {
return line(lineData.slice(0, interpolate(f)));
};
}