differenceY = (data, options) => {
class DifferenceY extends Plot.Area {
constructor(data, {x, y1, y2, ...options} = {}) {
y1 = maybeZero(y1);
y2 = maybeZero(y2);
super(data, {...options, x1: x, x2: undefined, y1, y2});
}
render(I, scales, {x1: X, y1: Y1, y2: Y2 = Y1}, {width}) {
const g = super.render(...arguments);
const uid = DOM.uid();
const line = d3.line().x(i => X[i]).y(i => Y1[i]).curve(this.curve);
d3.select(g)
.style("clip-path", uid)
.append("defs")
.append("clipPath")
.attr("id", uid.id)
.append("path")
.attr("d", `
${line(I)}
L${width},${Y1[I[I.length-1]]} L${width},0 L0,0 M${width},${Y1[I[0]]} Z`
);
return g;
}
}
return new DifferenceY(data, options);
}