forked from mthalves/dash_cm_plot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdash_layout.py
More file actions
executable file
·117 lines (99 loc) · 3.42 KB
/
dash_layout.py
File metadata and controls
executable file
·117 lines (99 loc) · 3.42 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# -*- coding: utf-8 -*-
import base64
import datetime
import io
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State, Event
import pandas as pd
from utils import *
from title import *
from fileselect import *
from analysisselect import *
from plotinfoselect import *
from ackandcreators import *
from mylayouts import *
from myinput import *
from radioitems import *
from upload import *
from droplist import *
from button import *
from image import *
import Novonix_Protocol
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
file = []
app.layout = html.Div(
style={'width': '100%', 'height': '100%',
'backgroundColor': colors['background'],
'backgroundImage': 'url(https://i.redd.it/ev89ehtc0o2x.png)'
},
children=[
Title_and_Introduction(),
html.Div(
children = [
Select_File(),
Select_Analysis(),
Select_Plot_Information(),
ButtonHTML('PLOT','plot_button'),
html.Div(id='plot_click'),
], style={ 'width': '60%', 'height': '95%',
'marginLeft': '20%',
'marginRight': '20%',
'marginTop': '5%',
'borderWidth': '1px',
'borderStyle': 'outset',
'borderRadius': '5px',
'backgroundColor': colors['background'],
},
),
Acknowledgment_and_Creators(),
]
)
def get_csv(contents, filename, date):
content_type, content_string = contents.split(',')
decoded = base64.b64decode(content_string)
try:
if 'csv' in filename:
# Assume that the user uploaded a CSV file
df = pd.read_csv(
io.StringIO(decoded.decode('utf-8')),
error_bad_lines = False)
elif 'xls' in filename:
# Assume that the user uploaded an excel file
df = pd.read_excel(
io.BytesIO(decoded),
error_bad_lines = False)
except Exception as e:
print(e)
return html.Div([
'There was an error processing this file.'
])
print(df)
return df.to_dict('records')
@app.callback(Output(component_id='output-data-upload', component_property='children'),
[Input(component_id='upload-data', component_property='contents')],
[State('upload-data', 'filename'),
State('upload-data', 'last_modified')])
def file_callback(list_of_contents, list_of_names, list_of_dates):
print(list_of_names)
if list_of_contents is not None:
children = [
parse_contents(c, n, d) for c, n, d in
zip(list_of_contents, list_of_names, list_of_dates)]
global file
file = get_csv(list_of_contents[0], list_of_names[0], list_of_dates[0])
return children
@app.callback( Output(component_id='plot_click', component_property='children'),
[],
[],
[Event('plot_button','click')],
)
def plot_callback():
global file
print('plotting')
#return Novonix_Protocol.CoulombicEfficiency(file)
return Novonix_Protocol.DVA(file,[5,10])
if __name__ == '__main__':
app.run_server(debug=True)