forked from kordc/SpotifyPlaylistAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout.py
250 lines (233 loc) · 10.1 KB
/
layout.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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
import dash_bootstrap_components as dbc
from dash import dcc, html
from utils.valueBox import get_value_box
import utils.constants as C
from utils.help import HELP
navbar = dbc.Navbar(
dbc.Container(
[
html.A(
# Use row and col to control vertical alignment of logo / brand
dbc.Row(
[
dbc.Col(
html.Img(src="https://i.ibb.co/db0jXmq/logo-no-bg.png", height="60ex")),
],
align="left",
className="g-0",
),
# href="NASZ ADRES POZNIEJ",
style={"textDecoration": "none"},
),
dbc.Button("Help", id="open", n_clicks=0),
dbc.Modal(
[
dbc.ModalHeader(dbc.ModalTitle("Welcome to Spotify Analyzer!"), style={'align':'center'}),
dbc.ModalBody(HELP),
dbc.ModalFooter(
dbc.Button(
"Close", id="close", className="ms-auto", n_clicks=0
)
),
],
id="modal",
size='xl',
scrollable=True,
is_open=True,
),
]
),
# color="dark",
# dark=True,
)
search_card = dbc.Card(
dbc.CardBody(
[
dbc.Row([
dbc.Col([
dcc.Dropdown(options=[
{'label': 'Different top 50',
'value': 'assets/Different_top_50.csv'},
{'label': 'Different genres',
'value': 'assets/Different_genres.csv'},
{'label': 'Different modes',
'value': 'assets/Different_modes.csv'},
],
id=C.PRE_DROP,
placeholder="Select one of the predefined datasets"),
], width=3, style={"border-right": "2px solid #1DB954"}),
dbc.Col([
dbc.Input(id=C.SEARCH_PHRASE,
type="text",
placeholder="search for artist/track/playlist",
style={"width": "100%"},
debounce=True),
dbc.RadioItems(options=[
{"label": "track", "value": "track"},
{"label": "playlist",
"value": "playlist"},
{"label": "album",
"value": "album"},
],
value="track",
id=C.SEARCH_TYPE,
inline=True,
label_style={
"margin-right": "30px"},
inputStyle={"margin-right": "5px"}),
], width=3),
dbc.Col([
dbc.Button('Search', id=C.SEARCH_BUTTON, n_clicks=0,
style={"height": "90%"}, outline=True, color="success", className="me-1")
], width=1, style={"border-right": "2px solid #1DB954", 'text-align': 'center'}),
dbc.Col([
dcc.Dropdown(options=[],
id=C.UNDO_DROP,
placeholder="Undo one of the steps"),
], width=2),
dbc.Col([
dbc.Button('Reset', id=C.RESET_BUTTON, n_clicks=0, style={"height": "90%"},
outline=True, color="danger", className="me-1"),
], width=1, style={"border-right": "2px solid #1DB954", 'text-align': 'center'}),
dbc.Col([
#7 of these components are needed as it works only if one output is connected with one component
dbc.Spinner(html.Div(id=C.LOADING_PREDEFINED), color="success",spinner_style=C.SPINNER_STYLE),
dbc.Spinner(html.Div(id=C.LOADING_SEARCH), color="success",spinner_style=C.SPINNER_STYLE),
dbc.Spinner(html.Div(id=C.LOADING_RESET), color="success",spinner_style=C.SPINNER_STYLE),
dbc.Spinner(html.Div(id=C.LOADING_UNDO), color="success",spinner_style=C.SPINNER_STYLE),
dbc.Spinner(html.Div(id=C.LOADING_REMOVAL), color="success",spinner_style=C.SPINNER_STYLE),
dbc.Spinner(html.Div(id=C.LOADING_FILTER), color="success",spinner_style=C.SPINNER_STYLE),
dbc.Spinner(html.Div(id=C.LOADING_SELECT), color="success",spinner_style=C.SPINNER_STYLE),
])
]),
]
), style={'text-align': 'center'}
)
radar_card = dbc.Card(
dbc.CardBody(
[
html.H2("General statistics"),
dbc.Row(dcc.Dropdown(options=[
{'label': "Average everything",
'value': 'average'},
{'label': 'By query',
'value': 'by_query'},
{'label': 'Each song separately',
'value': 'separate'},
],
id=C.RADAR_DROPDOWN,
placeholder="Select the behaviour of radar plot"),
),
dbc.Row(dcc.Graph(id=C.RADAR))
], style={'height': '100%', 'text-align': 'center'}
)
)
top_card = dbc.Card([
dbc.CardBody([
dbc.Col([
html.H2("Top songs"),
dbc.Row([
dcc.Slider(5, 20, 5,
value=5,
id=C.TOP_N_SLIDER),
dbc.Col(dcc.Dropdown(options=[{'label': attr, "value": attr} for attr in C.NUMERICAL_COLUMNS],
id=C.TOP_N_ATTR,
placeholder="Top 5 in...")),
dbc.Col(dcc.Dropdown(options=[{'label': attr, "value": attr} for attr in C.NUMERICAL_COLUMNS],
id=C.TOP_N_COLOR,
placeholder="color based on"),
)
]
),
dbc.Row(
dcc.Graph(id=C.TOP_N_PLOT))
], width=6, style={'width': '100%', 'height': '556px', 'text-align': 'center'})
], style={'text-align': 'center'})
])
parallel_lines_card = dbc.Card([
dbc.CardBody([
html.H2("Parallel Coordinates Plot"),
dbc.Col([
dbc.Row(dbc.Col(dbc.Checklist(options=[],
id=C.PARALLEL_COORDS_QUERIES, inline=True))),
html.Hr(),
dbc.Row(dbc.Col(dbc.Checklist(options = [{'label': x, 'value': x} for x in C.NUMERICAL_COLUMNS], value= [C.NUMERICAL_COLUMNS[0]],
id=C.PARALLEL_COORDS_ATTR, inline=True))),
dbc.Row(
dcc.Graph(id=C.PARALLEL_COORDS))
], width=6, style={'width': '100%', 'height': '508px'})
], style={'text-align': 'center'})
])
sun_card = dbc.Card([
dbc.CardBody([
html.H2("Compare data on a sunchart"),
dbc.Row([
dbc.Col([dbc.Input(id=C.SUNBURST_TEXT,
type="text",
placeholder="order of categorical variables separated by comma e.g mode, explicit, time_signature",
debounce=True),
html.P(f'available attributes: {", ".join(C.CATEGORICAL_COLUMNS)}')], width=11, style={'text-align': 'center'}),
dbc.Col(dbc.Button('Update', id=C.SUNBURST_SUBMIT, n_clicks=0,
style={"height": "90%"}, outline=True, color="success", className="me-1"), width=1),
dcc.Graph(id=C.SUNBURST)
], style={'margin': 'auto'})
], style={'text-align': 'center'})
], style={'margin-top': '15px'})
scatter_card = dbc.Card([
dbc.CardBody([
html.H2("Scatterplot"),
dbc.Row(([
dbc.Col([
html.P("x"),
dcc.Dropdown(options=[attr for attr in C.NUMERICAL_COLUMNS],
id=C.SCATTER_X,
value=C.NUMERICAL_COLUMNS[0]),
html.P("y"),
dcc.Dropdown(options=[attr for attr in C.NUMERICAL_COLUMNS],
id=C.SCATTER_Y,
value=C.NUMERICAL_COLUMNS[1]),
html.P("color"),
dcc.Dropdown(options=[attr for attr in C.CATEGORICAL_COLUMNS],
id=C.SCATTER_COLOR,
value=C.CATEGORICAL_COLUMNS[0]),
html.P("rug type"),
dcc.Dropdown(options=["box", "violin", "rug", "histogram"],
id=C.SCATTER_RUG,
value="box"),
]),
dbc.Col(dcc.Graph(id=C.SCATTER), width=9)
]))
], style={'text-align': 'center'})
], style={'margin-top': '15px'})
def get_layout(table, footers_definitions):
layout = dbc.Card([
dbc.CardBody([
navbar,
search_card,
dbc.Row(
[dbc.Col(dbc.Card(get_value_box(**parameters), color='success', inverse=True))
for parameters in footers_definitions],
className="mb-4",
id=C.FOOTER, style={'margin-top': '15px'}),
dbc.Row([
dbc.Col([
dbc.Card(
dbc.CardBody(
[
html.H2("List of all songs"),
dbc.Table(table)
], style={'text-align': 'center'}
)
)
], width=6, style={}),
dbc.Col(radar_card, width=6, style={})
], style={'margin-top': '15px'}), # style={"display": "none"} We could possibly use this to hide the graph entirely
dbc.Row([
dbc.Col(top_card),
dbc.Col(parallel_lines_card)
], style={'margin-top': '15px'}),
sun_card,
scatter_card
], style={'margin': '0 6% 0 6%', 'background': '#ECF0F5'})
], style={'background': '#ECF0F5'})
return layout