plot icon indicating copy to clipboard operation
plot copied to clipboard

Stack overlapping, non-aligned intervals?

Open fgregg opened this issue 1 year ago • 2 comments
trafficstars

Currently, if two rects do not share an x1 and x2, they will not stack, it would be great if they did!

Here's an example of something i would like to stack but is not:

untitled(88)

https://observablehq.com/@fgregg/chicago-shelter-eviction-rates@129

I manually set offsets to look like this:

untitled(89)

https://observablehq.com/@fgregg/chicago-shelter-eviction-rates@171

fgregg avatar Jan 11 '24 00:01 fgregg

The GitHub Burndown chart does something like this by converting an interval into a regular pulse (e.g., daily value). It’s not technically possible to stack rects with overlapping but non-aligned intervals because the resulting stacked shape is no longer a rect. For example, say you have two intervals represented in ASCII art:

aaaaaaaaaa
    bbbb

If you were to stack a on top of b, the shape for a would no longer be a rectangle:

    aaaa
aaaabbbbaa

The stack transform doesn’t require that the independent dimension (normally x) is regular, so you wouldn’t have to take the pulse approach used in the linked notebook — you could instead cut every interval when it overlaps with another interval. And then the stack transform would work. Maybe the bin transform could do something fancy here to replicate data that spans multiple bins.

mbostock avatar Jan 11 '24 00:01 mbostock

this is the behavior i’d like to see:

    aaaa
aaaabbbbaa

and you are absolutely right that is not a rect anymore, so it probably shouldn’t be something you can do with rects.

however, stacking up bits of area of different widths would still be really useful! at least to me.

fgregg avatar Jan 11 '24 00:01 fgregg