I want to allow the user to choose which columns of a data frame one wants to see on y. I tried so much meanwhile but I still can’t get it to work. I followed Line charts in Python but there is actually not an example given according to my needs.
The possible columns to choose from are ['V+', 'V-', 'I_tube', 'I_heat'].
My code so far is:
app = Dash(__name__)
app.layout = html.Div(
style = {},
children = [
html.H4('test'),
dcc.Graph(id="graph"
),
html.Br(),
dcc.Checklist(
id="signals",
options = ['V+', 'V-', 'I_tube', 'I_heat'],
value = ['V+'],
inline=True
),
]
)
@app.callback(
Output("graph", "figure"),
Input("signals", "value")
)
def update_line_chart(signals):
#df = all_df[all_df.columns == signals]
df = all_df
fig = px.line(df
, x = "time"
#, y = "I_heat"
#, y = df[signals]
#, y = signals['value']
#, y = df['value']
#, y = all_df.columns == signals['value']
, color = 'Device'
, hover_name="Device"
, template = 'plotly_dark'
)
fig.update_layout(transition_duration=500)
return fig
app.run_server()
I’m highly thankful for any input!