Sagar
Sagar

Reputation: 67

D3js Line graph doesn't go through all of my points when I use .interpolate('basis')?

When I try to use .interpolate('basis') an incorrect path is showing in my graph. When it changes to .interpolate('linear') it fixes the issue. How can I fix this issue even if I use .interpolate('basis'). Here is the plunker http://plnkr.co/edit/dGjaHXZ186JYzX8IUahw?p=preview Please help me.

Upvotes: 2

Views: 135

Answers (2)

skl
skl

Reputation: 21

Interpolation in D3 represent some mathematical equation to join the different points with a line. Even you can customize the behavior of the interpolations if you feel the default types provided by D3 are not satisfying your needs. These resources can be helpful.

D3 Documentation Link

Example to visualize different interpolations

Upvotes: 1

Lars Kotthoff
Lars Kotthoff

Reputation: 109242

I assume that by "incorrect" you mean "doesn't go through all of my points". The basis interpolation uses a b-spline which does not have this property -- there's no way to "fix" it, this is simply how it behaves.

You may consider the cardinal interpolation instead, which also gives you a smooth curve, but goes through all the points as well. Example here.

Upvotes: 4

Related Questions