import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.express as px
# Initialize the Dash app
app = dash.Dash(__name__)
# Define the app layout
app.layout = html.Div([
    dcc.Upload(
        id='upload-data',
        children=html.Div([
            'Drag and Drop or ',
            html.A('Select Files')
        ]),
        style={
            'width': '100%',
            'height': '60px',
            'lineHeight': '60px',
            'borderWidth': '1px',
            'borderStyle': 'dashed',
            'borderRadius': '5px',
            'textAlign': 'center',
            'margin': '10px'
        },
        multiple=False
    ),
    dcc.Graph(id='graph')
])
# Define the callback to process the uploaded file and create the graph
@app.callback(
    Output('graph', 'figure'),
    Input('upload-data', 'contents')
)
def update_graph(contents):
    if contents is not None:
        content_type, content_string = contents.split(',')
        decoded = base64.b64decode(content_string)
        df = pd.read_excel(io.BytesIO(decoded))
        fig = px.scatter(df, x="x_column", y="y_column")  # Replace with your desired plot type and columns
        return fig
if __name__ == '__main__':
    app.run_server(debug=True)