Pad domain addition?

Open
#150 15 comments 7 reactions 0 assignees View on GitHub

@curran is already working on this.

Since Jun 17, 2020.

  • #213 by @curran — open

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
10/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript

Research direction

The issue proposes adding a padDomain API to scales and links to a proposed implementation in src/utils/padScale.js. Read that implementation and the linked open pull request #213 to understand the existing proposal and discussion. The issue has been inactive for years and already has a pull request open, so work is underway; no completion criteria are stated.

Written by the indexing model from the issue text.

Description

When I'm making scatter plots (and others), I find myself padding the scale's domain by the pixel radius of my circles to avoid them overlapping with the y-axis. I specify the number of pixels I want to increase on the left and right side of the domain, use the scale's inverse to add or subtract that amount from the domain and use that result to reset it.

I made a convenience function to do this and was curious if you would want a PR if this seems like useful functionality.

The api could be something like:

scaleLinear()
  .domain([0, 100])
  .range([0, 200])
  .padDomain([10, 10])
// new domain is [-5, 105]

[edited for better order of operations in the API example]

Dominant language
JavaScript
Stars
1.6k
Forks
288
Avg merge
6h 41m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from d3/d3-scale

All issues in d3/d3-scale

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.