Levin-Aleksey commited on
Commit
129b1de
·
1 Parent(s): 7fdfd9e
Files changed (1) hide show
  1. app.py +29 -32
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
- chart_col, debug_col = st.columns([4, 1])
142
-
143
- with chart_col:
144
- st.caption("Native chart (always on)")
145
- st.area_chart(df_cohorts, x="cohort_day", y="user_count", use_container_width=True)
146
-
147
- try:
148
- st.caption("Plotly chart")
149
- fig = px.area(df_cohorts, x="cohort_day", y="user_count", template="plotly")
150
- st.plotly_chart(fig, use_container_width=True)
151
- except Exception as exc:
152
- st.warning(f"Plotly не отрисован: {exc}")
153
-
154
- if IS_HF_SPACE:
155
- st.caption("HF mode: fallback enabled")
156
-
157
- st.caption("Server-rendered fallback (matplotlib)")
158
- mpl_fig, mpl_ax = plt.subplots(figsize=(9, 3.5))
159
- mpl_ax.plot(df_cohorts["cohort_day"], df_cohorts["user_count"], linewidth=2)
160
- mpl_ax.fill_between(df_cohorts["cohort_day"], df_cohorts["user_count"], alpha=0.25)
161
- mpl_ax.set_xlabel("cohort_day")
162
- mpl_ax.set_ylabel("user_count")
163
- mpl_ax.grid(alpha=0.2)
164
- st.pyplot(mpl_fig, use_container_width=True)
165
- plt.close(mpl_fig)
166
-
167
- with debug_col:
168
- st.caption("Chart debug")
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, use_container_width=True)
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"):