Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curve tension is weird in d3 v4

When creating a cardinal curve in d3 v3, I would use tension(.0) to create a certain curve. However, in d3 v4, the tension seems to have been changed. To get the same curve, I need to use tension(-1.3). This shouldn't even work, since the tension should be between 0 and 1.

Fiddle for the v3: https://jsfiddle.net/diogoscf/5st4wk7c/

Fiddle for the v4 that should work but doesn't: https://jsfiddle.net/diogoscf/3xma5wxu/

Fiddle for the v4 that shouldn't work but does: https://jsfiddle.net/diogoscf/3xma5wxu/2/

Is this a bug in d3 v4? I don't want to exploit bugs since they could get patched and break my code, but this is the only way it seems to work. If there's another way, please inform.

like image 421
Diogo SCF Avatar asked Mar 08 '23 05:03

Diogo SCF


1 Answers

I don't think it's a bug since catmullRom with alpha 0 yield the same result as it should, curveNatural gives the closest result to what you are expecting, using negative tension values is a bad idea, it shouldn't even draw the line.

like image 107
Marcell Monteiro Cruz Avatar answered Mar 19 '23 17:03

Marcell Monteiro Cruz