holtzy / D3-graph-gallery

A collection of simple graphics made with D3.js
https://www.d3-graph-gallery.com
MIT License
790 stars 237 forks source link

Examples not working with newest release V5. #22

Open dcts opened 4 years ago

dcts commented 4 years ago

I just noticed that the examples do not work with the newest d3.js release (v5). It took me forever to find out that this happens because the data loading with d3.csv() and d3.json() now supports promise based syntax. So instead of writing

<script src="https://d3js.org/d3.v4.js"></script>

<script>
  d3.csv(url, function(data) {
    // ...
  });
</script>

You can write

<script src="https://d3js.org/d3.v5.min.js"></script>

<script>
  d3.csv(url).then(function(data) {
    // ...
  }).catch(function(error) => {
    console.log(error);
  });
</script>

Thought i share it here maybe worth updating all the examples? If you want me to do it let me know, I could invest some time. Really thank you for providing this great page, really helpful.

holtzy commented 4 years ago

Thank you very much for this feedback.

Indeed, the gallery is currently all made for d3.v4... And I'm not sure what my plan is concerning the v5 since it would be a lot of work to migrate it all and many ppl still use the v4.

I'm considering adding a v4/v5 toggle button but I don't have time for it currently..

What do you think the best option is?

dcts commented 4 years ago

hey @holtzy , sorry for the late reply! My personal opinion is that its best to have everyone switch to the newest version, rather than providing multi version support for tutorials. I think if someone is using this tutorial page to learn d3.js, he or she should just use the newest version,since most of the time newer versions hold improvements. And if you have already a project in another version, its a good incentive to upgrade :)

But this is only valid if the newest version does not depricate functionality without replacing it. So if there is stuff you can do with v4 but not v5, this becomes a whole new discussion. But for that to decide i dont know enough about D3js.