# Plotly.js Plotting a variable number of lines

**URL:** <https://community.plotly.com/t/plotly-js-plotting-a-variable-number-of-lines/59741>\
**Category:** plotly.js\
**Created:** [January 3, 2022, 8:38pm UTC](https://community.plotly.com/t/plotly-js-plotting-a-variable-number-of-lines/59741 "2022-01-03T20:38:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![abick](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@abick](https://community.plotly.com/u/abick)\
**Post date:** [January 3, 2022, 8:38pm UTC](https://community.plotly.com/t/plotly-js-plotting-a-variable-number-of-lines/59741/1 "2022-01-03T20:38:22Z")

</div>

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
