-
Notifications
You must be signed in to change notification settings - Fork 184
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
ignore infinite values when setting a scale domain? #528
Comments
If we want to do this, it should probably happen when we coerce numbers (#532): Lines 189 to 194 in 916d04b
For example, we could check that the value is finite: function coerceNumber(x) {
return x == null || !isFinite(x = +x) ? NaN : x;
} However, I’m not sure that this is a good universal behavior… it feels convenient to treat infinite values as undefined to make sure that the chart renders correctly, but the infinite values are (technically) defined so it might be preferable to throw an error or show a warning instead. #536 |
The line is blurry: a mathematician would say that 1/0 and log(0) are undefined, but JavaScript wants them Infinite. In my use case, the data was the magnitude of a computational error over 100 tests. When the error for one of the 100+ tests fell to 0 (a situation which I hadn't anticipated), the y axis crashed, which was not helpful. This patch works very well; in this notebook, I tried several alternatives… in each case it means you have to understand why the chart collapsed, then think about a solution. (I'd also want a warning, of course.) |
This proposal is also consistent with #279. In other words, this chart:
should not fail, but behave as this one (which is our log-degenerate.js test case), only with log(d) on the x axis:
|
I was doing an error plot and because one of the values was infinite (log(0)), the y scale collapsed. it would be more useful in that case to ignore the infinite value (as NaN), and report the missing / invalid point when we have some way of logging warnings.
The text was updated successfully, but these errors were encountered: