-
Notifications
You must be signed in to change notification settings - Fork 187
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
Revert fancy range behavior. #5
Comments
The workaround used in d3/d3#2524 still applies:
does not find mismatches in firefox; still need to test in chrome. This suggests a similar fix, eg. adjust stop by (1-eps) * stop . Thinking a bit more about it, it is probably necessary to adjust the difference between start and stop, rather than just stop; eg. use (stop - start)*(1-eps) to determine n. |
Here is a gist which does some checks of the range() function. http://bl.ocks.org/andreasplesch/ada4b4e89738d4e5d4af It turns out the workaround is useful but not very good for larger offsets (larger numbers) even when using the (stop-start)*(1-eps) adjustment . |
Well, I decided to go back to integer ranges. Perhaps it is worthwhile to add to the documentation that if the number of elements in the generated array is expected to be exactly n, then one should use something like
or perhaps provide this as another range function, say d3.nrange(), which takes start, step and number of elements n. |
Illustrate floating point precision issue with example range and suggest using .map on integer range instead. See issue d3#5 .
Hmm. I’m tempted to remove the scale hack entirely, since it only works for some cases and makes the behavior harder to understand. In general, you shouldn’t expect |
Related d3/d3#494, D3 version 2.7.5, commit d3/d3@87f48b7. |
Perhaps with the original commit above I now can understand what the conversion to integer is about but it did make the behaviour more opaque. I would say remove it, and perhaps emphasize the limitations a bit more in the documentation. |
Re-opening this request, because I think you are right that we should remove the fancy behavior. |
Fixed in 0.1.2; see d2364d4. |
While the new range() function is improved, it still produces an extra element for some fractional step sizes.
Also see d3/d3#2524
A fix may have to take into account limited floating point precision, in a similar way to pull request
d3/d3#2526
The problem is
which is upped to 50 by Math.ceil().
The text was updated successfully, but these errors were encountered: