ridgeLine = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
let nbColor = 10;
let linearGradient = svg
.append("linearGradient")
.attr("id", "Gradient2")
.attr('gradientUnits', "userSpaceOnUse")
.attr("x1", "0")
.attr("x2", "0")
.attr("y1", 25)
.attr("y2", 0);
linearGradient
.selectAll("stop")
.data(d3.range(nbColor).reverse())
.join("stop")
.attr("offset", (d, i) => `${i / (nbColor - 1)}`)
.attr("stop-color", (d, i) =>
interpolator(invertColor ? 1 - i / (nbColor - 1) : i / (nbColor - 1))
);
for (var i = 0; i < elevationMatrix.length; i += 7) {
var g = svg.append('g').attr('transform', `translate(0,${y(i)})`);
g.selectAll('.lines')
.data([elevationMatrix[i]])
.enter()
.append('path')
.attr('class', 'lines')
.attr('stroke', 'black')
.attr('fill', 'none')
.attr('stroke-width', 1.2)
.attr('d', line);
g.selectAll('.areas')
.data([elevationMatrix[i]])
.enter()
.append('path')
.attr('class', 'areas')
.attr("fill", "url(#Gradient2)")
.attr("opacity", opacity)
.attr("d", (d, i) => area(d));
}
return svg.node();
}