observablehq / observablehq/plot

smarter autoheight for ordinal scales?

Open
#1,239 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

autoHeight with the default round:true option sometimes leaves too much white space. In the chart below it returns a value of 580, when ideally it should be 556px.

Plot.plot({
  x: {
    percent: true,
    label: "Frequency (%) →"
  },
  height: 556,
  y: {
    label: null
  },
  marks: [
    Plot.gridX({interval: 1}),
    Plot.axisX({anchor: "top"}),
    Plot.axisX({anchor: "bottom", label: null}),
    Plot.barX(alphabet, {x: "frequency", y: "letter", fill: "steelblue"}),
    Plot.ruleX([0])
  ]
})

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

Reproduce the supplied Plot example with autoHeight and the default round:true option, comparing the returned 580px height with the intended 556px. Trace the ordinal-scale height calculation and add coverage showing that autoHeight avoids the excess whitespace while preserving rounded heights where appropriate.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.