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

better error message for missing stack value #1798

Merged
merged 3 commits into from
Aug 9, 2023
Merged

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Aug 9, 2023

Originally, I tried this:

Plot.rectY(
  series,
  Plot.pointerX({
    x: "time",
    y: null,
    interval: {
      floor: (x) => Math.floor(x) - 0.5,
      offset: (x) => x + 1
    }
  })
),

This leads to a vague error:

TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))

The error can be reproduced as:

Plot.valueof([], null, Float64Array)

In the context of valueof, I think the error is okay: if you specify an array type then (I guess?) the value argument must not be null. But in the broader context of the stack transform, the stackY transform requires that y not be null since it will subsequently dereference those values even if we allowed valueof to return null here. So I think it’s better that we abort early with a more helpful error message.

Eventually I realized I could use rect instead of rectY, and by not specifying y, the rect spans the vertical extent of the chart and I don’t need rectY’s implicit stacking. I think this makes a nice test based on #1795.

@mbostock mbostock requested a review from Fil August 9, 2023 15:35
@mbostock mbostock force-pushed the mbostock/stack-null branch from 8a717a6 to e431364 Compare August 9, 2023 21:51
@mbostock mbostock enabled auto-merge (squash) August 9, 2023 21:52
@mbostock mbostock merged commit 99397d9 into main Aug 9, 2023
@mbostock mbostock deleted the mbostock/stack-null branch August 9, 2023 21:55
Fil pushed a commit that referenced this pull request Aug 21, 2023
* better error message for missing channel

* linked pointer example

* shorten error message
chaichontat pushed a commit to chaichontat/plot that referenced this pull request Jan 14, 2024
* better error message for missing channel

* linked pointer example

* shorten error message
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.

2 participants