I'm using d3.js 3.4.13, and the docs say the callback function for d3.json(data, callback)
should be of the format callback(error, responseData)
, however, I found that it actually sets the data to the first parameter, and the second parameter is unnecessary, so I use callback(responseData)
instead. It works, but I'm confused why it doesn't work the same way I interpreted the docs to describe it. What am I missing?
相关问题
- Is there a limit to how many levels you can nest i
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- How to toggle on Order in ReactJS
- StackExchange API - Deserialize Date in JSON Respo
A quick look at the source reveals the following function:
D3 explicitly checks the number of arguments to the callback through
.length
and if there's only one, puts the data in it.So the one-argument version is a convenience version that still works as expected.