-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
214 lines (204 loc) · 6.84 KB
/
utils.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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
import math
import dash_table
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
import pandas as pd
millnames = ['',' Thousand',' Million',' Billion',' Trillion']
currency = "€"
def round_nb(n):
return round(n)
def show_nb(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])
def show_nb_with_currency(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])+" "+currency
def show_percent(n):
if n > 0:
return "+"+str(round(n))+"%"
return str(round(n))+"%"
def create_table(df, label_X, label_Y, label_year=None, label_percent=None):
if label_year is None and label_percent is None:
df.columns = [label_X,label_Y]
elif label_percent is not None:
df.columns = [label_X, label_Y, label_percent]
else:
df.columns = [label_year, label_X,label_Y]
table = html.Div([
dash_table.DataTable(
id='datatable-interactivity',
columns=[
{"name": i, "id": i, "deletable": False, "selectable": True} for i in df.columns
],
style_cell={'textAlign': 'left'},
data=df.to_dict('records'),
#editable=True,
filter_action="native",
sort_action="native",
sort_mode="multi",
#column_selectable="single",
#row_selectable="multi",
#row_deletable=True,
#selected_columns=[],
#selected_rows=[],
page_action="native",
page_current= 0,
page_size= 10,
),
html.Div(id='datatable-interactivity-container')
])
return table
def feedback_table(df):
table = html.Div([
dash_table.DataTable(
id='datatable-feedback',
columns=[
{"name": i, "id": i, "deletable": False, "selectable": True} for i in df.columns
],
style_cell={'minWidth': '80px', 'textAlign': 'left', 'padding': '5px', 'whiteSpace': 'normal',
'height': 'auto'},
style_as_list_view=True,
style_header={
'backgroundColor': 'white',
'fontWeight': 'bold'
},
style_data_conditional=[
{
'if': {'row_index': 'odd'},
'backgroundColor': 'rgb(248, 248, 248)'
}
],
data=df.to_dict('records'),
#editable=True,
filter_action="native",
sort_action="native",
sort_mode="multi",
#column_selectable="single",
#row_selectable="multi",
#row_deletable=True,
#selected_columns=[],
#selected_rows=[],
page_action="native",
page_current= 0,
page_size= 5,
),
html.Div(id='datatable-feedback-container')
])
return table
def terminology():
terms = [
html.Span(
"ordinary buget",
id="term1",
style={"cursor": "pointer"},
className="tag"
),
dbc.Tooltip(
"revenues and expenses that occur at least once per fiscal year and provide for regular revenues and operations.",
target="term1",
),
html.Span(
"service revenue",
id="term3",
style={"cursor": "pointer"},
className="tag"
),
dbc.Tooltip(
"revenues for which the municipality provides a work, supply or service in return.",
target="term3",
),
html.Span(
"transfer revenue",
id="term4",
style={"cursor": "pointer"},
className="tag"
),
dbc.Tooltip(
"revenues for which the municipalities do not contribute directly.",
target="term4",
),
html.Span(
"debt revenue",
id="term5",
style={"cursor": "pointer"},
className="tag"
),
dbc.Tooltip(
"revenues from the Commune's receivables and assets.",
target="term5",
),
html.Span(
"staff expense",
id="term6",
style={"cursor": "pointer"},
className="tag"
),
dbc.Tooltip(
"salaries of the municipal staff (statutory and contractual) as well as the agents.",
target="term6",
),
html.Span(
"operating expense",
id="term7",
style={"cursor": "pointer"},
className="tag"
),
dbc.Tooltip(
"expenses essential to the proper functioning of the Commune, with the exception of personnel expenses.",
target="term7",
),
html.Span(
"transfer expense",
id="term8",
style={"cursor": "pointer"},
className="tag"
),
dbc.Tooltip(
"the legally obligatory financial interventions (e.g., hospital and public utilities deficits, police zones) and optional subsidies to various sports, cultural and philanthropic associations.",
target="term8",
),
html.Span(
"debt expense",
id="term9",
style={"cursor": "pointer"},
className="tag"
),
dbc.Tooltip(
"the repayment of the debt (capital and interest), whether it is borne by the municipality, a third party or the higher authority.",
target="term9",
),
html.Br(),
html.Hr(),
html.Span(
"extraordinary buget",
id="term2",
style={"cursor": "pointer"},
className="tag"
),
dbc.Tooltip(
"exceptional revenues and expenses relating to investments: major repairs to buildings or roads, purchases of buildings, etc.",
target="term2",
),
html.Span(
"investment revenue",
id="term10",
style={"cursor": "pointer"},
className="tag"
),
dbc.Tooltip(
"revenues from the municipality's own funds, e.g., from the sale of property, from planning charges",
target="term10",
),
html.P(
[
dcc.Link([
"More details",
], href='https://translate.google.com/translate?sl=fr&tl=en&u=http://www.ixelles.be/site/270-Budget-communal', target="_blank", className="spansm text-right no-decor sm-font text-blue"),
], className="text-right"),
]
return terms