Skip to content

Commit

Permalink
using the new Spreadsheet API
Browse files Browse the repository at this point in the history
  • Loading branch information
aarondr77 committed Nov 7, 2023
1 parent 9e97ccc commit 54d98c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
15 changes: 7 additions & 8 deletions app-mito.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
from dash import Dash, html, callback, Input, Output, dcc, dash_table, State
from dash.exceptions import PreventUpdate
import base64
from mitosheet.mito_dash.v1 import Spreadsheet, mito_callback

import io
import plotly.express as px
from mitosheet.mito_dash.v1 import Spreadsheet, mito_callback, activate_mito
from utils import get_correlation_df, get_graph_group

app = Dash(__name__)
activate_mito(app)

app.layout = dmc.MantineProvider(
[
Expand Down Expand Up @@ -107,7 +105,7 @@

html.Div(
[
Spreadsheet(id='spreadsheet', import_folder='data'),
Spreadsheet(id={'type': 'spreadsheet', 'id': 'sheet'}, import_folder='data'),
],
style={"height": "80%", "maxWidth": "80%", "margin": "auto", "padding": "10px"},
),
Expand Down Expand Up @@ -154,9 +152,10 @@
)

@callback(
Output("spreadsheet", "data"),
Output({'type': 'spreadsheet', 'id': 'sheet'}, "data"),
[Input("upload-data", "contents")],
[State("spreadsheet", "data")])
[State({'type': 'spreadsheet', 'id': 'sheet'}, "data")]
)
def update_spreadsheet_data(uploaded_contents, data):
if uploaded_contents is None:
raise PreventUpdate
Expand All @@ -178,7 +177,7 @@ def update_spreadsheet_data(uploaded_contents, data):
@mito_callback(
Output("graph-output", "children"),
Output("correlation-table", "children"),
Input("spreadsheet", "spreadsheet_result"),
Input({'type': 'spreadsheet', 'id': 'sheet'}, "spreadsheet_result"),
)
def update_outputs(spreadsheet_result):
if spreadsheet_result is None or len(spreadsheet_result.dfs()) == 0:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ dash-mantine-components
dash
dash-pivottable
pandas
plotly
plotly
mitosheet
3 changes: 1 addition & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,4 @@ def get_graph_group(df, date_columns):
side_by_side_graphs,
moving_average_graph
]
)

)

0 comments on commit 54d98c5

Please sign in to comment.