Mike Bostock (creator of D3) has a bunch of great code examples on bl.ocks.org.
I would start with his General Update Pattern (the link below goes through 1-3), which is key to understanding D3 as binding data to SVG elements (hence the name Data-Driven Documents) and animating any transitions.
General Update Pattern: https://bl.ocks.org/mbostock/3808218
Also the documentation is great, so check out the intro here:
https://d3js.org/#introduction
btw, if you're using D3 purely for charting, expect a lot of work to get something that looks decent. There charting libraries that have taken care of the styling and add functions on top of D3 to make your life easier.