D3 v5 Line Chart
D3 v4 Line Chart Example
This is a example for basic line chart using D3. We are using the newest version of D3, version 4. As for all visualizations, we can break down this work into a checklist.
Line Chart Checklist
- Add an SVG to draw our line chart on
- Use the D3 standard margin convetion
- Create an x axis
- Create a y axis
- Create an x scale
- Create a y scale
- Create a line generator
- Create a random dataset
- Create a path object for the line
- Bind the data to the path object
- Call the line generator on the data-bound path object
- Add circles to show each datapoint
- Add some basic styling to the chart so its easier on the eyes
Read through the code below to see where each part of the checklist is completed.
forked from pstuffa's block: D3 v4 Line Chart
forked from gordlea's block: D3 v5 Line Chart