D3 - Difference between basis and linear interpolation in SVG line

后端 未结 1 1560
野的像风
野的像风 2020-12-10 02:14

I implemented a multi-series line chart like the one given here by M. Bostock and ran into a curious issue which I cannot explain myself. When I choose linear interpolation

相关标签:
1条回答
  • 2020-12-10 03:17

    The basis interpolation is implementing a beta spline, which people like to use as an interpolation function precisely because it smooths out extreme peaks. This is useful when you are modeling something you expect to vary smoothly but only have sharp, infrequently sampled data. A consequence of this is that resulting line will not connect all data points, changing the appearance of extreme values.

    In your case, the sharp peaks are the interesting features, the exception to the typically 0 baseline value. When you use a spline interpolation, you are smoothing over these peaks.

    Here is a fun demo to play with the different types of line interpoations: http://bl.ocks.org/mbostock/4342190

    You can drag the data around so they resemble a sharp peak like yours, even click to add new points. Then, switch to a basis interpolation and watch the peak get averaged out.

    Basis interpolation

    0 讨论(0)
提交回复
热议问题