facet = {
const chart = new G2.Chart({ width, paddingLeft: 50 });
const rect = chart
.rect()
.scale("x", {
guide: { position: "bottom" },
domain: d3
.groupSort(
stateages,
(D) => d3.sum(D, (d) => -d.population),
(d) => d.state
)
.slice(0, 6)
})
.data(stateages)
.encode("x", "state");
rect
.interval()
.frame(false)
.scale("x", { guide: null })
.scale("y", { guide: { formatter: d3.format("~s"), grid: false } })
.scale("color", { range: d3.schemeSpectral[ages.length] })
.encode("x", "age")
.encode("y", "population")
.encode("color", "age");
return node(chart.render());
}