tiffylou
tiffylou

Reputation: 546

Loosen spine, smooth line in D3js

I want to smooth a line in D3js. I started with this: image1

After looking through the documentation, I added interpolate("basis") - I also tried all the other options. Basis is a good start.

image2

But I want to loosen the curve even more...abstract it away from it's data points to see the general spine formation. Like so:

image3

By removing data points I can force a smoother line, but I am wondering if there is a better way to do this? An existing method that I might be able to take advantage of. Any ideas?

My code is pretty standard, so I didn't provide it here. Let me know if you need something more.

Upvotes: 3

Views: 325

Answers (1)

tiffylou
tiffylou

Reputation: 546

Thanks for all the suggestions. I found this psuedocode to be a great place to start for line smoothing: https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm

Here is an existing js library achieving a similar goal: http://mourner.github.io/simplify-js/

Upvotes: 1

Related Questions