How do I put multiple traces onto a scatter figure is my data is coming from a csv file with ever-changing values?
I have a hierarchy for my data. It is state, city, month, and sales. I am designing a 2 by 2 dashboard, with 2 charts on the top row and two on the bottom row. I want to tell two different stories:
On the top row, compare year-to-date sales by state in one chart and then to its right, compare year-to-date sales by cities within a selected state. With the help of contributors to this forum, I was able to get the state chart to work and interactively select cities for the city chart.
On the bottom row are 2 charts showing year-to-date sales by month for all states and having a trace per state. (For now I am not working on the 4th chart which is month by city.) Currently, I have 4 states in my csv file, so I need to show 4 traces. I will be adding more as time goes on, and I would like the chart to dynamically add or remove traces based on what is in the csv file.
What I think I need to do is build a dataframe of just the unique states, then use this in a for loop to build a trace per state. The values would be x=month and y = sales for each trace. I am not sure how to do this though.
Can anyone suggest code or a reference url that shows how to build this scatter figure?