Move graph and table elements into callback function

master
Dan Howe 5 years ago
parent 857aea677b
commit 97f79bbab8

@ -41,7 +41,7 @@ app.layout = html.Div([
])
def parse_contents(contents, filename, date):
def parse_contents(contents, filename):
basename, ext = os.path.splitext(filename)
content_type, content_string = contents.split(',')
decoded = base64.b64decode(content_string)
@ -147,22 +147,23 @@ def parse_contents(contents, filename, date):
},
)
elements = html.Div([
graph_timeseries, graph_energy, table_energy,
html.Div(id='datatable-row-ids-container')
])
return elements
return graph_timeseries, graph_energy, table_energy
@app.callback(Output('output-data-upload', 'children'), [
Input('upload-data', 'contents'),
Input('upload-data', 'filename'),
Input('upload-data', 'last_modified'),
])
def update_output(contents, name, date):
def update_output(contents, name):
if contents is not None:
return parse_contents(contents, name, date)
graph_ts, graph_spec, table_spec = parse_contents(contents, name)
elements = html.Div([
graph_ts, graph_spec, table_spec,
html.Div(id='datatable-row-ids-container')
])
return elements
else:
return html.Div([])

Loading…
Cancel
Save