anscombe = {
console.log("width", width);
const maxCellWidth = Math.min(250, width * 0.4);
console.log("width", width, "maxCellWidth", maxCellWidth);
const hover = vl
.selectSingle()
.nearest(true)
.on("mouseover")
.init({ X: [], Y: [] });
const base = vl
.markCircle({ size: 100, tooltip: true })
.encode(
vl.x().fieldQ("X"),
vl.y().fieldQ("Y"),
vl.color().value("steelblue").if(hover, vl.value("firebrick")),
vl.detail().fieldN("Series")
)
.width(maxCellWidth)
.height(maxCellWidth);
return vl
.layer(
base.select(hover),
base
.markLine()
.transform(vl.regression("Y").on("X"))
.encode(vl.color().value("#777"))
)
.facet(vl.facet().fieldN("Series"))
.data("data/anscombe.json")
.columns(2)
.config({ axis: { grid: false } })
.render();
}