viewof regression = {
await vg
.coordinator()
.exec([
vg.loadObjects("athletes", FileAttachment("athletes.parquet").parquet())
]);
const $query = vg.Selection.intersect();
const $x = vg.Param.value(numFields[0].value);
const $y = vg.Param.value(numFields[1].value);
const $color = vg.Param.value(stringFields[0].value);
return vg.vconcat(
vg.hconcat(
vg.menu({ label: "X-axis", as: $x, options: numFields }),
vg.menu({ label: "Y-axis", as: $y, options: numFields }),
vg.menu({ label: "Color", as: $color, options: stringFields })
),
vg.plot(
vg.dot(vg.from("athletes"), {
x: vg.sql`${$x}`,
y: vg.sql`${$y}`,
fill: vg.sql`${$color}`,
r: 2,
opacity: 0.05
}),
vg.regressionY(vg.from("athletes", { filterBy: $query }), {
x: vg.sql`${$x}`,
y: vg.sql`${$y}`,
stroke: vg.sql`${$color}`
}),
vg.intervalXY({
as: $query,
brush: { fillOpacity: 0, stroke: "currentColor" }
})
)
);
}