Open danburzo opened 6 years ago
I was looking for that too, would be a great addition, along with the other interpolation functions in https://bl.ocks.org/emmasaunders/f7178ed715a601c5b2c458a2c7093f78 that seem to be readily available for svg lines in d3.
I came looking here for a monotone interpolation implementation as well. :/ Since there existed a monotone curve option in d3-shape
I expected it to be available in d3-interpolate
.
I've experimented with monotone cubic interpolation (as per the Steffen method you reference in d3-shape) and with the array values being evenly spaced, the formula is quite simplified, as long as I read the paper correctly:
where
h = 1 / n
,t1 = t - i / n
andi
,n
, andv0
...v3
being computed the same as with the basis spline.I tried it for the purpose of color interpolation, although it turned out to be of questionable usefulness, at least in RGB:
Nevertheless, if you think it would be a good addition to d3-interpolate, I'm happy to make a PR. (Could be useful for animations, since it smoothly interpolates the data points?)