Skip to content
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

Error in d3.json function or advertised in the wrong way! #3559

Closed
RiadOkba opened this issue Mar 7, 2022 · 2 comments
Closed

Error in d3.json function or advertised in the wrong way! #3559

RiadOkba opened this issue Mar 7, 2022 · 2 comments

Comments

@RiadOkba
Copy link

RiadOkba commented Mar 7, 2022

The function d3.json doesn't deliver as explained in many tutorials. In every tutorials, they considered d3.json as d3.csv but for JSON format. So they explain this would work:
d3.json("./data/users.json", function(error, data) {
d3.select("body").selectAll("p").data(data).enter().append("p").text(function(d) {
return d.name + ", " + d.location;
});
});

It doesn't ! Viewing the code in d3.v7.js, the d3.json should work like so:
d3.json("./data/users.json").then ( data => {
d3.select("body").selectAll("p").data(data).enter().append("p").text(function(d) {
return d.name + ", " + d.location;
});
});

So if I'm not wrong, either d3 module should be readjusted making d3.json works in the same logic as d3.csv or all tutorials about d3.json in the web needs to be informed about the mistake...

Please if I'm wrong correct me.

@Fil
Copy link
Member

Fil commented Mar 7, 2022

you're right; unfortunately no one has the capacity to reach out to every tutorial author on the internet

@Fil Fil closed this as completed Mar 7, 2022
@curran
Copy link
Contributor

curran commented Mar 7, 2022

The API changed in v5. Details are here https://github.com/d3/d3/blob/main/CHANGES.md#changes-in-d3-50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants