Repository navigation
numeric interval & documentation - #552
Merged
Merged
Conversation
mbostock
requested changes
Sep 24, 2021
| // chose between UTC and local time (or better, an explicit timeZone option). | ||
| function maybeInterval(interval) { | ||
| if (interval == null) return; | ||
| if (typeof interval === "number" && interval) { |
Member
There was a problem hiding this comment.
What’s the truthy interval test for? Testing for nonzero, non-NaN? I think I’d prefer to drop this because it’s not sufficient to ensure good behavior (for example, Infinity or -Infinity will produce NaN below), and it’s just simpler to avoid trying.
Suggested change
| if (typeof interval === "number" && interval) { | |
| if (typeof interval === "number") { |
Alternatively, we could ignore NaN specifically:
Suggested change
| if (typeof interval === "number" && interval) { | |
| if (typeof interval === "number" && !isNaN(interval)) { |
This will still break for zero and infinities, but those are at least considered defined values, so it’s probably reasonable that it breaks.
Contributor
Author
There was a problem hiding this comment.
I'm OK with not trying :)
| if (interval == null) return; | ||
| if (typeof interval === "number" && interval) { | ||
| const n = interval; | ||
| interval = { floor: d => n * Math.floor(d / n), offset: d => d + n }; |
Member
There was a problem hiding this comment.
Suggested change
| interval = { floor: d => n * Math.floor(d / n), offset: d => d + n }; | |
| // Note: this offset doesn’t support the optional step argument for simplicity. | |
| interval = {floor: d => n * Math.floor(d / n), offset: d => d + n}; |
| * **y2** - the ending vertical position; bound to the *y* scale | ||
|
|
||
| Typically either **x1** and **x2** are specified, or **y1** and **y2**, or both. The rect mark supports the [standard mark options](#marks), including insets and rounded corners. The **stroke** defaults to none. The **fill** defaults to currentColor if the stroke is none, and to none otherwise. | ||
| Typically either **x1** and **x2** are specified, or **y1** and **y2**, or both. **x1** and **x2** can be derived from **x** and an **interval** object (such as d3.utcDay) with a **floor** method that returns *x1* from *x* and an **offset** method that returns *x2* from *x1*. If the interval is specified as a (non-null) number, *x1* and *x2* are taken as the two consecutive multiples of *n* that bracket *x*. The interval may be specified either as as {x, interval} or x: {value, interval}—typically to apply different intervals to x and y. |
Member
There was a problem hiding this comment.
Suggested change
| Typically either **x1** and **x2** are specified, or **y1** and **y2**, or both. **x1** and **x2** can be derived from **x** and an **interval** object (such as d3.utcDay) with a **floor** method that returns *x1* from *x* and an **offset** method that returns *x2* from *x1*. If the interval is specified as a (non-null) number, *x1* and *x2* are taken as the two consecutive multiples of *n* that bracket *x*. The interval may be specified either as as {x, interval} or x: {value, interval}—typically to apply different intervals to x and y. | |
| Typically either **x1** and **x2** are specified, or **y1** and **y2**, or both. **x1** and **x2** can be derived from **x** and an **interval** object (such as d3.utcDay) with a **floor** method that returns *x1* from *x* and an **offset** method that returns *x2* from *x1*. If the interval is specified as a number (and not NaN), *x1* and *x2* are taken as the two consecutive multiples of *n* that bracket *x*. The interval may be specified either as as {x, interval} or x: {value, interval}—typically to apply different intervals to x and y. |
mbostock
approved these changes
Sep 24, 2021
mbostock
pushed a commit
that referenced
this pull request
Sep 24, 2021
mbostock
added a commit
that referenced
this pull request
Sep 24, 2021
* interval for rect * default insets for intervals * Update src/transforms/interval.js * numeric interval & documentation (#552) * interval for rule and bar * Update CHANGELOG Co-authored-by: Philippe Rivière <fil@rezo.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.