observablehq / observablehq/plot

Centered/aligned intervals?

Open
#1,774 0 comments 1 reaction 1 assignee View on GitHub

@Fil is already working on this.

Since Jul 31, 2023.

enhancement
Dominant language
HTML
Stars
5.4k
Forks
244
PR merge metrics
No merged PRs in 30d

Description

interval: 1 or interval: day respectively create [0, 1] and [monday 00:00, monday 23:59:59…] segments, that can be represented as, say, a barX. In some cases we'd prefer the bar to be centered on the value.

This can be done currently with a custom interval: {floor: d => Math.floor(d) - 0.5, offset: (d, n=1) => d + n}, but it could be nice to have a shorthand notation.

maybe intervalAlign: 0.5 (with a default being 0, or 1 depending on the semantics we'd want to give it).

For UTC intervals, we'd have to get a sense of what is an appropriate “day shifted by a fraction”—including when days are 23 or 25 hours-long, or months.

A typical use case: https://talk.observablehq.com/t/observable-plot-cell-and-date-label/8116

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.