Created
September 15, 2018 11:45
-
-
Save prabhant/410523a66b74a1b40d8d28167cae8a69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.layout = html.Div([ | |
html.H2('Tolareports'), | |
dcc.Dropdown( | |
value='2017', | |
options=[{'label': i, 'value': i} for i in ['2017', '2018']], | |
multi=False, | |
id='dropdown-year', | |
placeholder="Select Year",), | |
dcc.Graph(id = 'table-1-1'), | |
dcc.Graph(id = 'table-1-2'), | |
]) | |
@app.callback(Output('intermediate-value', 'children'), [Input('dropdown-year', 'value')]) | |
def common_table(year): | |
df = pd.read_csv('file.csv') | |
df = df['year'] | |
#more recurring computations | |
return df.to_json(date_format='iso', orient='split') | |
@app.callback(Output('table-1-1', 'figure'), [Input('intermediate-value', 'children')]) | |
def table_1(cleaned_data): | |
df_1 = pd.read_json(cleaned_data, orient = 'split') | |
df_t = df1['column name'] | |
for i in range(len(list(df_t)): | |
vals.append(df_t.iloc[:, i]) | |
return { | |
'data': [ | |
go.Table( | |
columnwidth=[150, 40, 40, 40, 40, 40, 40, 40,40], | |
header=dict(values=list(df_t.columns), | |
font=dict(family='Roboto', size=16, color='#143945'), | |
fill=dict(color='#ffffff')), | |
cells=dict( | |
values=vals, | |
font=dict(family='Roboto', size=14, color='#333333'), | |
fill=dict(color='#ffffff'), | |
align=['left'] * 5) | |
) | |
] | |
} | |
@app.callback(Output('table-1-1', 'figure'), [Input('intermediate-value', 'children')]) | |
def table_1(cleaned_data): | |
df_1 = pd.read_json(cleaned_data, orient = 'split') | |
df_t = df1['column name'] | |
for i in range(len(list(df_t))): | |
vals.append(df_t.iloc[:, i]) | |
return { | |
'data': [ | |
go.Table( | |
columnwidth=[150, 40, 40, 40, 40, 40, 40, 40,40], | |
header=dict(values=list(df_t.columns), | |
font=dict(family='Roboto', size=16, color='#143945'), | |
fill=dict(color='#ffffff')), | |
cells=dict( | |
values=vals, | |
font=dict(family='Roboto', size=14, color='#333333'), | |
fill=dict(color='#ffffff'), | |
align=['left'] * 5) | |
) | |
] | |
} | |
@app.callback(Output('table-1-2', 'figure'), [Input('intermediate-value', 'children')]) | |
def table_2(cleaned_data): | |
#different computations but same as table_1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment