Update a graph with a column in a dataframe selected by dropdown

Hi,

I’ll try to do that. I have a dataframe, and in my dropdown I have the columns headers.

options = [col1, col2, col3…]

dcc.Dropdown (id=test, options = options),
dcc.Graph(id=testg)

@app.callback(
Output(“testg”, “figure”),
[Input(“test”, “value”),

def update_fig(value):
data
trace = go.Scatter(x=(df.time),
y= df [‘value’],
line=dict(color…

But didnt works, how to select the y in function of column, selected by dropdown?

Thx so much1

Hi,

Welcome to the community!

Try to use value unquoted in y=df[value]. Just be aware that value can be None when the app starts, so this has to be handled somehow (preventing the initial call or handling a none explicitly in the callback).

So many thx!!!. WORKS! :smiling_face: