Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rangeInclusive? #90

Closed
curran opened this issue Jan 28, 2019 · 3 comments
Closed

rangeInclusive? #90

curran opened this issue Jan 28, 2019 · 3 comments

Comments

@curran
Copy link

curran commented Jan 28, 2019

I frequently find myself using d3.range and desiring an inclusive range. I end up writing code like this:

d3.range(min, max, step).concat(max)

Since this appears rather cryptic, I thought I'd propose this clearer alternative:

d3.rangeInclusive(min, max, step)

This comes up at least once a month in my day to day work, I wonder if this is true for others as well.

Anyone else think this would be a useful addition to d3-array?

@Fil
Copy link
Member

Fil commented Mar 7, 2019

I usually do something like d3.range(min, max+0.001) :)

@Fil
Copy link
Member

Fil commented Jun 11, 2020

Closing this issue due to inactivity. Please do not hesitate to add a comment or reopen the issue if you think it is still worth pursuing.

PS: I think I like d3.range(min, max, step).concat(max) better, because it's more explicit (one less documentation item to know). Also I'd favor documenting d3.ticks(0,1,1000) which covers half the use cases.

@Fil Fil closed this as completed Jun 11, 2020
@mbostock
Copy link
Member

We could also introduce a linspace method as in numpy. It functions more like d3.ticks, except it doesn’t attempt to produce human-readable values.

https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants