Skip to content

The rect mark could work better with band scales #1899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mbostock opened this issue Oct 20, 2023 · 0 comments · Fixed by #1909
Closed

The rect mark could work better with band scales #1899

mbostock opened this issue Oct 20, 2023 · 0 comments · Fixed by #1909
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

mbostock commented Oct 20, 2023

Currently the rect mark is a bit pedantic regarding band scales — it generally requires that you specify x1, x2, y1, y2 explicitly. So in a situation like this, you see nothing:

untitled (99)

Plot.plot({
  marks: [
    Plot.rectX(data, {x1: "start", x2: "end", y: "name"})
  ]
})

You have to switch to barX to see what you likely intend:

untitled (100)

Plot.plot({
  marks: [
    Plot.barX(data, {x1: "start", x2: "end", y: "name"})
  ]
})

A related question is whether we could automatically infer the band scale for y (rather than the default point). That would also be necessary for the rect to appear.

Another possibility, to at least show something that maybe guides someone to a better outcome, would be to apply default negative insets in the case whether the rect would otherwise have zero width or height.

untitled - 2023-10-20T111404 886

Plot.plot({
  marks: [
    Plot.rectX(data, {x1: "start", x2: "end", y: "name", inset: -0.5})
  ]
})

Notebook: https://observablehq.com/d/87107ffe90ae73be

@mbostock mbostock added the enhancement New feature or request label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant