I have a data as below in a .csv file.
dataDescription 3-Aug-21 4-Aug-21 5-Aug-21 6-Aug-21 7-Aug-21
Latency_PRL 551.08 551.34 551.55 551.74 551.9
Supliment_PRL 552.5 552.8 553.3 553.65 553.95
Variant_PRL 582.52 583.06 583.38 583.68 584.02
Heat_PRL 870.37 870.63 870.37 870.2 870.42
Humidity_PRL 889.77 889.8 889.9 889.93 890.08
Latency_PS 117.69 120.1 122.08 123.84 125.53
Supliment_PS 100.14 101.2 103 104.27 105.36
Variant_PS 12.65 13.29 13.68 14.05 14.47
Heat_PS 7.37 7.67 7.38 719 7.43
Humidity_PS 34.57 34.63 34.94 35.03 35.51
Latency_Index 15012 32829 27850 24319 24716
Supliment_Index 12904 16613 21496 19396 16037
Variant_Index 2440 7363 4567 4282 4867
Heat_Index 3220 6619 4518 7487 12557
Humidity_Index 5605 6457 11978 11709 11532
This is actually 3 different tables in 1. If you look at the column dataDescription, you will notice that the first 5 rows have ‘PRL’ , the second 5 have ‘PS’ and the last five have ‘Index’. So, first five rows is one set of data, the 2nd five the next set & so on.
I want to build 3 line charts (one for 'PRL, another for PS & one more for Index).
I am able to filter the data for each item as below & do not know how to proceed further.
d3.csv("info.csv").then((item) =>
item
.map((item) => {
const values = item.dataDescription.split("_");
return { attributeA: values[0], attributeB: values[1], ...item };
})
.filter((item) => item.attributeB === "PRL")
);
The output is an array but the dates are keys them selves instead of values.
So, the 2 question I have is
- How to I make a Line chart (just for PRL for now)
- Do I have to repeat the code 3 times is i have to build 3 line charts (in actual data, there are many more items & I would like to avoid writing the code multiple times)?
I am a newbie to JS & D3, so please guide. Thanks.

icon on the right to replace the sample data.csv with your real CSV. The charts will update automatically (so long as the columns work the same way in the real CSV).