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

expose {number,time,utc}Interval #2075

Merged
merged 6 commits into from
Jun 11, 2024
Merged

expose {number,time,utc}Interval #2075

merged 6 commits into from
Jun 11, 2024

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Jun 8, 2024

Fixes #1994.

@mbostock mbostock requested a review from Fil June 8, 2024 17:54
@mbostock mbostock enabled auto-merge (squash) June 8, 2024 18:15
docs/features/intervals.md Outdated Show resolved Hide resolved
@mbostock mbostock requested a review from Fil June 11, 2024 14:57
@Fil
Copy link
Contributor

Fil commented Jun 11, 2024

The negative intervals encoding fractional values is something that might be surprising—but I understand if we want to gloss over that.

@mbostock
Copy link
Member Author

The negative intervals encoding fractional values is something that might be surprising—but I understand if we want to gloss over that.

It took me a while to interpret this statement but you’re referring to Plot.numberInterval(-2) being the more precise version of Plot.numberInterval(1/2)?

@Fil
Copy link
Contributor

Fil commented Jun 11, 2024

yes!

@mbostock
Copy link
Member Author

Okay, added more documentation, please approve.

Plot.numberInterval(2)
```

Given a number *period*, returns a corresponding range interval implementation. If *period* is a negative number, the resulting interval uses 1 / -*period*; this allows more precise results when *period* is a negative integer. The returned interval implements the *interval*.range, *interval*.floor, and *interval*.offset methods.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Given a number *period*, returns a corresponding range interval implementation. If *period* is a negative number, the resulting interval uses 1 / -*period*; this allows more precise results when *period* is a negative integer. The returned interval implements the *interval*.range, *interval*.floor, and *interval*.offset methods.
Given a number *period*, returns a corresponding range interval implementation. If *period* is a negative number, the resulting interval uses 1 / -*period*; this allows more precise results. The returned interval implements the *interval*.range, *interval*.floor, and *interval*.offset methods.

remove repeat — or did you mean "when period is a fractional value"?

Copy link
Member Author

@mbostock mbostock Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that’s what I meant, and no, I’m not repeating myself. There are two statements here:

  1. When period is a negative number, the resulting interval uses 1 / -period, and
  2. When period is a negative integer, the results are more precise as a result of (1).

If period is a negative number that is not a negative integer, it still works, but there’s not really any reason to do it. So these are saying two separate things.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I’m not documenting that a period of 0.5 is automatically promoted to -2, but I feel like that’s an implementation detail that doesn’t need to be documented.)

/**
* Given a number *period*, returns a corresponding numeric range interval. If
* *period* is a negative number, the returned interval uses 1 / -*period*,
* allowing greater precision when *period* is a negative integer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* allowing greater precision when *period* is a negative integer.
* allowing greater precision.

same suggestion/question

@mbostock mbostock merged commit 18e61e5 into main Jun 11, 2024
1 check passed
@mbostock mbostock deleted the mbostock/number-interval branch June 11, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to set numeric tick interval?
2 participants