This post describes how to build a line chart with several groups. Mind the Spaghetti chart: it becomes unreadable when too many lines are displayed. More examples of line charts in the dedicated section. This example works with d3.js v4
and v6
d3.nest
function to group the variable. Read more about it here.