Plotly.js Plotting a variable number of lines

I have an application that plots a line chart from a single trace.
I want to have users pick any number of unique traces (associated with a county) from a dropdown list and see the lines from each county they select.
The underlying data has three fields, “County”, “Year”, and “Population”. "Year will be on the X-axis, “Population” on the Y-axis

What is the best way to do this? Do I need to create multiple trace pairs? Can I apply a grouping variable (e.g. “County”)?
I see that “groupby” is being depreciated, what is a good alternative?

TIA