function trendLine(data, getX, getY, options) {
const points = data.map((d) => [getX(d), getY(d)]);
const [x1, x2] = d3.extent(points, (d) => d[0]);
const fit = ss.linearRegression(points);
const f = ss.linearRegressionLine(fit);
const [y1, y2] = [x1, x2].map(f);
return {
fit,
plot: Plot.line(
[
[x1, y1],
[x2, y2]
],
options
)
};
}