Skip to content

Conversation

@mbostock
Copy link
Member

@mbostock mbostock commented Mar 14, 2023

Fixes #1331.
Fixes #1240.

(Also fixes #1333 as a duplicate of #1240)

const interval = maybeInterval(thresholds);
if (interval !== undefined) return interval;
throw new Error(`invalid thresholds: ${thresholds}`);
return maybeUtcInterval(thresholds);
Copy link
Member Author

Choose a reason for hiding this comment

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

At this point, we’ve already checked that typeof thresholds === "string", so the other code paths should not be possible.

export interface AxisYOptions extends AxisOptions, TickYOptions {}

export interface GridXOptions extends GridOptions, RuleXOptions {}
export interface GridXOptions extends GridOptions, Omit<RuleXOptions, "interval"> {}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed because the rule mark allows a base (non-range) interval, whereas the grid mark requires a range interval. You can widen a type when extending, but you can’t narrow it.

@mbostock mbostock force-pushed the mbostock/range-interval branch from a25ccb0 to eb8587f Compare March 14, 2023 02:49
@mbostock mbostock changed the title strict range interval strict range interval, nice interval Mar 14, 2023
@mbostock mbostock marked this pull request as ready for review March 14, 2023 03:33
@mbostock mbostock requested a review from Fil March 14, 2023 03:33
@mbostock mbostock merged commit 0c963df into main Mar 14, 2023
@mbostock mbostock deleted the mbostock/range-interval branch March 14, 2023 20:41
chaichontat pushed a commit to chaichontat/plot that referenced this pull request Jan 14, 2024
* strict range interval

* nice intervals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants