This is the my first simple project using the D3.js library.
D3 Notes
-
The standard formatting of numbers by D3 is to put a thousands delimiter (a comma), since I wanted the numbers in the xAxis to represent years, I formatted the numbers using .tickFormat(d3.format("d")) on the xAxis. The complete line of code is: const xAxis = d3.axisBottom(xAxisScale).tickFormat(d3.format("d"))
-
While the previous version (3) of D3.js allowed calling the attr() method with an object containing the attributes and their values, this option has been removed from the standard D3 library. Now the same result can be achieved with the method attrs() and calling:
Of course this has as a result one more call to the server.
JavaScript Notes
To avoid using JQuery just to make a simple JSON request I used the fetch API.
CSS
I used flexbox to center my svg inside the page.
General
If I initiallize npm after I have created my github repo, the github links will populate automatically the package.json file.
Links
Fetch