Hi,
I am new to dash and python, and as a result I know I am doing something frustratingly dumb below.
I wanted to generate a list from files present in a designated folder that can be selected from a dropdown menu to plot. These are unique files that require the library pandas_access to generate a DataFrame.
Every time I select a file, nothing plots. Any issues with this function?
app = dash.Dash()
pathway = '/Users/Desktop/dash/data sets'
files = [f for f in listdir(pathway) if isfile(join(pathway, f))]
app.layout = html.Div([
dcc.Dropdown(id='filename',
options=[
{'label': i, 'value': i} for i in files
],
multi=True
),
dcc.Graph(id='graphs')
])
@app.callback(Output(component_id='graphs', component_property='figure'), [Input('filename', 'value')])
def analysis(values):
traces = []
for x in values:
df = pd.read_csv(x)
y = [go.Scatter(
x=df['Test_Time'],
y=df['Voltage'],
mode='markers',
opacity=0.7,
# name=str(x)),
)]
traces.append(y)
return {'data':traces,'layout': go.Layout(title='Dashboard',
xaxis={'title': 'Time'},
yaxis={'title': 'Voltage'})}
if __name__ == '__main__':
app.run_server()