Comments (4)
You’re probably using an old version of D3?
from d3.
As for the other cases, this:
d3.min(['5', '10', null, '2'], (d) => +d)
is equivalent to this:
d3.min(['5', '10', null, '2'].map((d) => +d))
is equivalent to this:
d3.min([5, 10, 0, 2])
hence it returns zero.
And likewise for d3.least, it doesn’t care that the element is null, it cares whether the return value of the given accessor is null. So if you coerce null to zero in your accessor, and zero is the least value, then d3.least will return the corresponding element which is null.
from d3.
Yes. Thank you. I know this is the expected behavior. The problem is that the accessor is not really being used to access anything, but to coerce and change values in the dataset, which can lead to cryptic code. Mislead by an example of mine where I used +d to coerce strings, my student spent a day trying to fix a bug and fixed it after removing nulls from her dataset. She had understood that extent should ignore nulls, but wasn't aware that they were being coerced.
from d3.
Yes, I recommend that you apply type coercion as early as possible — ideally when the data is loaded, say by using d3.autoType in conjunction with d3.csv, or Observable’s FileAttachment helper with typed: true. If you defer type coercion until later, there is much more surface area for these problems.
from d3.
Related Issues (20)
- searching “range” or “extent” doesn't find the expected page
- How to build this chart
- Adopt a monorepo
- grid color not applied for the left axis column number 1
- cycle at stratify err
- D3 graph into Flutter web
- Remember ui State across reloads HOT 1
- Nodes arrange
- Replace Math.random() with crypto function HOT 4
- Non english language texts being cut off HOT 4
- Zoom and click on d3 Sankey
- What does mean the sample code?
- #How to remove spaces between bar in d3.js grouped bar chart.
- d3 hierarchy: node visibility parameter to control either to show node in visualization or hide it.
- the wrong parameter name at Binning data of d3-array documentation HOT 5
- Upgrading from v3 to v7 requires additional renders for my custom gauge
- Making a non-contiguous piechart
- Transition to pie chart with 2 slices crashes HOT 1
- Adding a link towards DefinitelyTyped HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3.