observablehq / stdlib

The Observable standard library.
https://observablehq.com/@observablehq/standard-library
ISC License
957 stars 83 forks source link

Greater than filter shouldn't remove NaN values #339

Closed mkfreeman closed 1 year ago

mkfreeman commented 1 year ago

It feels odd that adding a greater than filter removes NaN values (which we bin into the invalid number category).

I would expect the NaN values to still be visible after applying this (persistent filter):

no filter: Image

with filter: (notice yellow bar is missing, as are NaN values from the table rows)

Image

mbostock commented 1 year ago

This seems like the desired behavior to me. Comparing anything with NaN is always false, so all undefined/null/NaN vales should be removed with any threshold comparison (>, <, >=, <=).

[1, 2, 3, 4, NaN].filter((x) => x > 2) // [3, 4]
annie commented 1 year ago

@mkfreeman do we still want to modify this behavior, or can we close this issue?