setting smoothing parameters in d3 js smoothing splines

267 views Asked by At

I'm trying to set the smoothing parameters (lambda) using one of the smoothing libraries in the d3 js (d3.curveBasis, curveBasisClosed ...etc), but I'm not sure how to do it. The following is exactly what I want -

http://bl.ocks.org/jonahwilliams/62be9996afe5c2531625

However, my x axis has dates and this doesn't seem to handle it well. I'm, ideally, looking for ways to modify existing libraries to add the smoothing parameter, lambda. Any help is appreciated.

Thanks

1

There are 1 answers

0
paligap On

What about something like this?

D3.js (Version 4)

var line = d3.line()
.curve(d3.curveMonotoneX) <-- Insert smoothing here
.x(function(d) { return x(d.x); })
.y(function(d) { return y(d.y); });

D3.js (Version 3)

var line = d3.svg.line()
.interpolate("monotone")
.x(function(d) { return x(d.x); })
.y(function(d) { return y(d.y); });

Perform the smoothing directly on the line you're plotting.