observablehq / observablehq/plot

Binning temporal data using the built-in _hours_ interval forces interval boundaries to start at midnight

Open
#2,452 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Consider the following plot invocation. Every hour there’s an event and I’m trying to bin them in intervals of 11 hours each.

Plot.plot({
  color: { legend: true, transform: null },
  marks: [
    Plot.barY(
      Array.from({length: 48}, (_, i) => (new Date(2026, 7, 1 + Math.floor(i / 24), i%24))),
      Plot.binY({fill: 'count'}, {y: { interval: '11 hours'}})
    )
  ]
})
Image

I expected each bin to be the same size (maybe expect the very last one). Instead each day is individually divided into two bins of size 11 hours and one bin of size 2 hours.

The same happens for every interval of which 24 hours isn’t an integer multiple (i.e., 5, 7, 9, …).

This might be related to https://github.com/observablehq/plot/discussions/2450

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.

Research direction

Start by reproducing the provided Plot.plot invocation and compare the 11-hour binning across the two days shown. Trace the built-in temporal interval handling used by Plot.binY; done means consecutive bins remain 11 hours wide, apart from a possible final partial bin, rather than resetting at midnight.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.