Another possibility would be to use faceting to create grouped bars. In this approach, you first have to pivot your data from wide to tall, like so:
flatdata = data.flatMap(d => ["y1", "y2", "y3", "y4", "y5", "y6"].map(name => ({date: d.x, name, value: d[name]})))
Then you can facet by month along x, and within each facet, group and sum by each name (y1, y2, etc.).
Plot.plot({
y: {
transform: d => d / 1e6
},
x: {
axis: null
},
fx: {
tickFormat: "%b-%y"
},
facet: {
data: flatdata,
x: d => d3.utcMonth(d.date)
},
marks: [
Plot.barY(flatdata, Plot.groupX({y: "sum"}, {x: "name", y: "value", fill: "name"})),
Plot.ruleY([0])
]
})
However, Plot won’t let you draw a continuous line across facets; facets in Plot are ordinal (discrete) rather than quantitative (continuous). That said, you could use additional discrete marks such as bars or rules to draw those other series.
Plot.plot({
y: {
transform: d => d / 1e6
},
x: {
axis: null
},
fx: {
tickFormat: "%b-%y"
},
facet: {
data: flatdata,
x: d => d3.utcMonth(d.date)
},
marks: [
Plot.barY(flatdata, Plot.groupZ({y: "sum"}, {filter: d => d.name === "y5", y: "value"})),
Plot.barY(flatdata, Plot.groupX({y: "sum"}, {filter: d => ["y1", "y2", "y3", "y4"].includes(d.name), x: "name", y: "value", fill: "name"})),
Plot.ruleY([0])
]
})