stack rect when rects are different widths

three groups of rectY, that overlap but with different widths the (x1 and x2).

I’d like the rectY to stack, but they are not.

Plot.plot({
  marks: [
    Plot.rectY(
      eviction_rate,
      Plot.stackY({
        x1: "start",
        x2: "end",
        y: (d) => d.count / ((d.end - d.start) / (1000 * 60 * 60 * 24)),
        fill: "group"
      })
    )
  ]
})

The stack transform works by identifying data that has a common x and then transforming the y values to sit on top of each other. I don’t think it will work if your rects have width (because what is “common”?)

I think to generate your data, you should start by creating an array that encompasses all dates in the range you’re interested in, and then populate it with the number of evictions in each group.

1 Like