-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
89 lines (69 loc) · 1.86 KB
/
app.py
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
import math
import pandas as pd
import flask
import dash
import dash_core_components as dcc
import dash_html_components as html
import dateutil.parser
#from sfManager import sf_Manager
server = flask.Flask(__name__)
app = dash.Dash(__name__, server=server)
app.config.suppress_callback_exceptions = True
#sf_manager = sf_Manager()
millnames = ["", " K", " M", " B", " T"] # used to convert numbers
# return html Table with dataframe values
def df_to_table(df):
return html.Table(
# Header
[html.Tr([html.Th(col) for col in df.columns])] +
# Body
[
html.Tr(
[
html.Td(df.iloc[i][col])
for col in df.columns
]
)
for i in range(len(df))
]
)
#returns most significant part of a number
def millify(n):
n = float(n)
millidx = max(
0,
min(
len(millnames) - 1, int(math.floor(0 if n == 0 else math.log10(abs(n)) / 3))
),
)
return "{:.0f}{}".format(n / 10 ** (3 * millidx), millnames[millidx])
#returns top indicator div
def indicator_one(color, text, id_value):
return html.Div(
[
html.P(
text,
className="twelve columns indicator_text_one"
),
html.P(
id = id_value,
className="indicator_value_one"
),
],
className="one_three columns indicator",
)
#returns top indicator div
def indicator_four(color, text, id_value):
return html.Div(
[
html.P(
text,
className="twelve columns indicator_text_four"
),
html.P(
id = id_value,
className="indicator_value_four"
),
],
className="four columns indicator",
)