Hi @yunyihuang
An example is taken from this post did some slight changes.
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import os
import pandas as pd
import plotly.graph_objects as go
app = dash.Dash(__name__)
pathway = '/app/data sets'
files = [os.path.join(pathway, f) for f in os.listdir(pathway) if os.path.isfile(os.path.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 = []
if values is not None:
for x in values:
df = pd.read_csv(x)
y = go.Scatter(
x=df['X'],
y=df['Y'],
mode='markers',
opacity=0.7,
# name=str(x)),
)
traces.append(y)
return {'data':traces,'layout': go.Layout(title='Dashboard',
xaxis={'title': 'X'},
yaxis={'title': 'Y'})}
else:
return {}
if __name__ == '__main__':
app.run_server(debug=True)
I hope this helps.