Commit ·
129b1de
1
Parent(s): 7fdfd9e
start
Browse files
app.py
CHANGED
|
@@ -138,41 +138,38 @@ if df_cohorts.empty:
|
|
| 138 |
if df_cohorts.empty:
|
| 139 |
st.warning("Нет данных для графика: users_by_cohorts и txs_per_day_by_cohorts пустые или невалидные.")
|
| 140 |
else:
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
st.
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
st.metric("Rows", len(df_cohorts))
|
| 170 |
-
st.metric("Min day", int(df_cohorts["cohort_day"].min()))
|
| 171 |
-
st.metric("Max day", int(df_cohorts["cohort_day"].max()))
|
| 172 |
|
| 173 |
# Guaranteed non-visual fallback for environments where JS charts are blocked.
|
| 174 |
with st.expander("Chart data preview"):
|
| 175 |
-
st.dataframe(df_cohorts,
|
| 176 |
|
| 177 |
# Проверка данных внизу
|
| 178 |
with st.expander("Raw Data"):
|
|
|
|
| 138 |
if df_cohorts.empty:
|
| 139 |
st.warning("Нет данных для графика: users_by_cohorts и txs_per_day_by_cohorts пустые или невалидные.")
|
| 140 |
else:
|
| 141 |
+
st.caption("Native chart (always on)")
|
| 142 |
+
st.area_chart(df_cohorts, x="cohort_day", y="user_count", height=400)
|
| 143 |
+
|
| 144 |
+
try:
|
| 145 |
+
st.caption("Plotly chart")
|
| 146 |
+
fig = px.area(df_cohorts, x="cohort_day", y="user_count", template="plotly")
|
| 147 |
+
fig.update_layout(height=400, margin=dict(l=20, r=20, t=20, b=20))
|
| 148 |
+
st.plotly_chart(fig)
|
| 149 |
+
except Exception as exc:
|
| 150 |
+
st.warning(f"Plotly не отрисован: {exc}")
|
| 151 |
+
|
| 152 |
+
if IS_HF_SPACE:
|
| 153 |
+
st.caption("HF mode: fallback enabled")
|
| 154 |
+
|
| 155 |
+
st.caption("Server-rendered fallback (matplotlib)")
|
| 156 |
+
mpl_fig, mpl_ax = plt.subplots(figsize=(9, 4))
|
| 157 |
+
mpl_ax.plot(df_cohorts["cohort_day"], df_cohorts["user_count"], linewidth=2)
|
| 158 |
+
mpl_ax.fill_between(df_cohorts["cohort_day"], df_cohorts["user_count"], alpha=0.25)
|
| 159 |
+
mpl_ax.set_xlabel("cohort_day")
|
| 160 |
+
mpl_ax.set_ylabel("user_count")
|
| 161 |
+
mpl_ax.grid(alpha=0.2)
|
| 162 |
+
st.pyplot(mpl_fig)
|
| 163 |
+
plt.close(mpl_fig)
|
| 164 |
+
|
| 165 |
+
st.caption("Chart debug")
|
| 166 |
+
st.metric("Rows", len(df_cohorts))
|
| 167 |
+
st.metric("Min day", int(df_cohorts["cohort_day"].min()))
|
| 168 |
+
st.metric("Max day", int(df_cohorts["cohort_day"].max()))
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
# Guaranteed non-visual fallback for environments where JS charts are blocked.
|
| 171 |
with st.expander("Chart data preview"):
|
| 172 |
+
st.dataframe(df_cohorts, width="stretch")
|
| 173 |
|
| 174 |
# Проверка данных внизу
|
| 175 |
with st.expander("Raw Data"):
|