observablehq / observablehq/plot

Axis label position: Allow customizing vertical position of axis label for Y axis

Open
#1,101 4 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

The distance between the axis label and the chart is customizable in one direction. It'd be great to be able to expose a setting for the other direction (or for styling it in general) to allow more flexibility.

.attr("dy", labelAnchor === "center"
               ? axis === "right"
                   ? "-0.32em"
                   : "0.75em"
               : labelAnchor === "bottom"
                   ? "1.4em"
                   : "-1em")

The last condition ("-1em") seems too tight for my chart:
Screen Shot 2022-10-25 at 10 53 19 AM

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

Search the repository for the shown .attr("dy", labelAnchor...) expression and read the surrounding axis-label implementation. Determine how axis-label positioning is currently configured and what API surface is appropriate; done means Y-axis labels support an additional vertical-position or styling setting without breaking existing placement behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
d3, javascript
Domain
data-visualization, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.