1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
import reader as rd
import figures as fgs
import os
import base64
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
uploadStyle = {
'width': '100%',
'height': '60px',
'lineHeight': '60px',
'borderWidth': '1px',
'borderStyle': 'dashed',
'borderRadius': '5px',
'textAlign': 'center'
}
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(className="row", children= [
dcc.Upload(id='upload-data', children=['Drag and Drop or ', html.A('Select a File')], style=uploadStyle, multiple=True),
html.Div(id='output-data-upload'),
])
def createLayout(fig):
return html.Div([
html.Div(className="six columns", style={"width": "100%", "height": "500px"}, children = [ dcc.Graph(id='timeline-graph', figure=fig)]),
] )
def decodeContent(content):
content_type, content_string = content.split(',')
return base64.b64decode(content_string)
@app.callback(dash.dependencies.Output('output-data-upload', 'children'),
dash.dependencies.Input('upload-data', 'contents'),
dash.dependencies.State('upload-data', 'filename'),
dash.dependencies.State('upload-data', 'last_modified'))
def update_output(list_of_contents, list_of_names, list_of_dates):
if list_of_names is None:
return []
if len(list_of_names) == 1:
name, ext = os.path.splitext(list_of_names[0])
if rd.hasExtension(list_of_names[0], ".zip"):
decoded = decodeContent(list_of_contents[0])
dfs = rd.openZipArchive(decoded)
return createLayout(fgs.create(dfs))
return []
if __name__ == '__main__':
app.run_server(debug=True)
|