improve bin type coercion #790
Merged
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.
If the input channel is strings (or some other non-numeric type), we now coerce to a number. Example:
https://observablehq.com/d/71b0a051aff775f2
If the input channel is a typed array, we now also convert to a plain Array. This avoids an additional copy in d3.bin (since Array.isArray is false for typed arrays):
https://github.com/d3/d3-array/blob/2f28f41005de2fbb69e99439fabec5eb8bce26f0/src/bin.js#L16
And it also ensures that when we call coerceDate, that we produce an Array of Date instances (not possibly e.g. Float64Array of numbers).
plot/src/transforms/bin.js
Line 187 in 8af35be
Fixes #789.