Built with blockbuilder.org
Just as all of you know that the magic come from paht's d attribute. Using function triangleData to generate a string which contain the d's value, such as:
m 0,0 -10.717967697244909,40 21.435935394489817,0 z
that is: pt1=(0,0), pt2=(-10.717967697244909,40) and pt3=(21.435935394489817,0)
then an erect triangle-path is generated.
Lowercase commond indicates that sibling points' coordinates of d-value is relative coordinate. So point pt2 is based on pt1, and pt3 is based on pt2, then on and on.
https://d3js.org/d3.v3.min.js