Closed Animus451 closed 7 years ago
A good suggestion! Current behavior is actually 2D catmull-rom splines. That means there's no favored independent variable or axis. Which in turn means, I guess, monotonic with respect to what? Which then means this would perhaps take the form of shape: 'spline' | 'monotonicx' | 'monotonicy'
. Or shape: 'spline', monotonic: false | 'x' | 'y'
, though the latter makes the 'smoothing' parameter unused for that case, which is just a bit awkward.
Paths are computed for use here and step paths (perhaps most similar to this case) are computed here. It would then be a matter of computing a monotonic path (in screen coordinates, I believe). The math is here.
It certainly seems reasonable and perhaps not even that difficult, though I don't believe it's currently on the radar. A PR would be gladly accepted though. Glad to help think it through, otherwise those are my thoughts on what it would take.
Thanks for pointing to #993 - it is indeed a duplicate, lets keep the discussion contained over there.
Currently, the spline technique that is employed for line charts and scatter plots seems to be some form of non-monotonic polynomial regression. Whatever method is used to generate the spline often distorts the data set to which the curve is being fit. (See below) The graph below shows false extrema as a result of the spline. While this kind of spline may work for some situations, a more generally useful spline would be a monotonic polynomial regression. This specifically prevents distorted representations of extrema.
Note: A similar issue has been opened here: https://github.com/plotly/plotly.js/issues/993