Skip to content

Pad domain addition? #150

@mhkeller

Description

@mhkeller

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions