Accepted answer

d3.ease already returns a number.

You just need to pass the value you want to d3.ease:


Here is a demo with "cubic-in", as in your question:

function ease(value) {
  return d3.ease("cubic-in")(value);

console.log("ease for 0.1: " + ease(4));
console.log("ease for 0.5: " + ease(0.5));
console.log("ease for 0.8: " + ease(0.8));
console.log("ease for 0.95: " + ease(0.95));
<script src=""></script>

Keep in mind that the passed value and the returned value are between 0 and 1. According to the API:

An easing function takes the current parameterized time value t in the domain [0,1], and maps it to another value in a similar range.

Related Query

More Query from same tag