referenceCurves = {
const statsSorted = stats.sort((a, b) => a.PERIODO - b.PERIODO);
const curvesColors = d3
.scaleSequential(
(t) => (console.log("t", t, 1 - t), d3.interpolatePurples(1 - t))
)
.domain([0, 3]);
function getCurve(sdDiff = 0) {
const avg = yAttr,
sd = `sqrt(var_pop(${yAttr.split("(")[1].slice(0, -1)}))`;
return {
name: `Avg +${sdDiff}sd`,
data: statsSorted.map((d) => [d.PERIODO, d[avg] + sdDiff * d[sd]]),
color: curvesColors(Math.abs(sdDiff)),
opacity: 0.7
};
}
return [-3, -2, -1, 0, 1, 2, 3].map(getCurve);
}