Spaces:
Sleeping
Sleeping
Update
Browse files- app_lib/viz.py +39 -26
- style.css +19 -3
app_lib/viz.py
CHANGED
|
@@ -17,35 +17,48 @@ def _viz_rank(results):
|
|
| 17 |
|
| 18 |
sorted_width = 1 - sorted_tau
|
| 19 |
sorted_width /= sorted_width.max()
|
| 20 |
-
sorted_width *=
|
| 21 |
|
| 22 |
m = min(len(concepts), 7)
|
| 23 |
nrows = np.ceil(len(sorted_concepts) / m).astype(int)
|
| 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 |
def _viz_test(results):
|
|
|
|
| 17 |
|
| 18 |
sorted_width = 1 - sorted_tau
|
| 19 |
sorted_width /= sorted_width.max()
|
| 20 |
+
sorted_width *= 80
|
| 21 |
|
| 22 |
m = min(len(concepts), 7)
|
| 23 |
nrows = np.ceil(len(sorted_concepts) / m).astype(int)
|
| 24 |
+
rank_el = ""
|
| 25 |
+
for concept_idx, concept in enumerate(sorted_concepts):
|
| 26 |
+
circle_style = (
|
| 27 |
+
"background: #418FDE;border-radius: 50%;width:"
|
| 28 |
+
f" {sorted_width[concept_idx]}px;padding-bottom:"
|
| 29 |
+
f" {sorted_width[concept_idx]}px;"
|
| 30 |
+
)
|
| 31 |
+
rank_el += (
|
| 32 |
+
"<div id='conceptContainer'><p"
|
| 33 |
+
f" id='concept'><strong>{concept}<strong></p><div id='circleContainer'><div"
|
| 34 |
+
f" style='{circle_style}'></div></div></div>"
|
| 35 |
+
)
|
| 36 |
+
print(rank_el)
|
| 37 |
+
st.markdown(rank_el, unsafe_allow_html=True)
|
| 38 |
+
# for i in range(nrows):
|
| 39 |
+
# cols = st.columns(m)
|
| 40 |
+
# for j in range(m):
|
| 41 |
+
# concept_idx = i * m + j
|
| 42 |
+
# if concept_idx >= len(sorted_concepts):
|
| 43 |
+
# break
|
| 44 |
+
# concept = sorted_concepts[concept_idx]
|
| 45 |
+
# col = cols[j]
|
| 46 |
+
# with col:
|
| 47 |
+
# circle_style = f"""
|
| 48 |
+
# background: #418FDE;
|
| 49 |
+
# border-radius: 50%;
|
| 50 |
+
# width: {sorted_width[concept_idx]}%;
|
| 51 |
+
# padding-bottom: {sorted_width[concept_idx]}%;
|
| 52 |
+
# """
|
| 53 |
+
# st.markdown(
|
| 54 |
+
# f"""
|
| 55 |
+
# <p id='concept'>
|
| 56 |
+
# <strong>{concept}</strong>
|
| 57 |
+
# </p>
|
| 58 |
+
# <div style='{circle_style}'></div>
|
| 59 |
+
# """,
|
| 60 |
+
# unsafe_allow_html=True,
|
| 61 |
+
# )
|
| 62 |
|
| 63 |
|
| 64 |
def _viz_test(results):
|
style.css
CHANGED
|
@@ -39,12 +39,28 @@ h1 {
|
|
| 39 |
}
|
| 40 |
}
|
| 41 |
|
| 42 |
-
[data-testid="stMarkdownContainer"]:has(> #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
display: flex;
|
| 44 |
flex-direction: column;
|
| 45 |
-
align-items:
|
|
|
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
}
|
| 49 |
|
| 50 |
.stSpinner>div {
|
|
|
|
| 39 |
}
|
| 40 |
}
|
| 41 |
|
| 42 |
+
[data-testid="stMarkdownContainer"]:has(> #conceptContainer) {
|
| 43 |
+
display: flex;
|
| 44 |
+
flex-wrap: wrap;
|
| 45 |
+
gap: 1rem;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
#conceptContainer {
|
| 49 |
+
flex: 1 1 auto;
|
| 50 |
display: flex;
|
| 51 |
flex-direction: column;
|
| 52 |
+
align-items: stretch;
|
| 53 |
+
}
|
| 54 |
|
| 55 |
+
#concept {
|
| 56 |
+
text-align: center;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
#circleContainer {
|
| 60 |
+
flex: 1;
|
| 61 |
+
display: flex;
|
| 62 |
+
justify-content: center;
|
| 63 |
+
align-items: center;
|
| 64 |
}
|
| 65 |
|
| 66 |
.stSpinner>div {
|