Переглянути джерело

feat: 更新数据展示组件,支持宽度自适应

zhch158_admin 1 місяць тому
батько
коміт
61c655ba39
1 змінених файлів з 5 додано та 5 видалено
  1. 5 5
      STREAMLIT_GUIDE.md

+ 5 - 5
STREAMLIT_GUIDE.md

@@ -230,7 +230,7 @@ def display_html_table_as_dataframe(self, html_content: str, enable_editing: boo
                     enable_sort = st.checkbox(f"启用排序", key=f"sort_{i}")
                 
                 # 显示表格
-                st.dataframe(table, use_container_width=True)
+                st.dataframe(table, width='stretch')
 ```
 
 ## 🔧 自定义开发
@@ -255,7 +255,7 @@ def create_table_visualization(df):
                 y=df[numeric_cols[0]],
                 title=f"{numeric_cols[0]} 分布"
             )
-            st.plotly_chart(fig, use_container_width=True)
+            st.plotly_chart(fig, width='stretch')
             
             # 创建散点图
             if len(numeric_cols) > 1:
@@ -265,7 +265,7 @@ def create_table_visualization(df):
                     y=numeric_cols[1],
                     title=f"{numeric_cols[0]} vs {numeric_cols[1]}"
                 )
-                st.plotly_chart(fig_scatter, use_container_width=True)
+                st.plotly_chart(fig_scatter, width='stretch')
 
 # 在主应用中使用
 if st.checkbox("显示数据可视化"):
@@ -282,7 +282,7 @@ def advanced_table_editor(df):
     # 数据编辑
     edited_df = st.data_editor(
         df,
-        use_container_width=True,
+        width='stretch',
         num_rows="dynamic",  # 允许添加删除行
         key="advanced_editor"
     )
@@ -459,7 +459,7 @@ def handle_large_tables():
         end_idx = min(start_idx + st.session_state.page_size, total_rows)
         current_df = df.iloc[start_idx:end_idx]
         
-        st.dataframe(current_df, use_container_width=True)
+        st.dataframe(current_df, width='stretch')
         st.info(f"显示第 {start_idx+1}-{end_idx} 行,共 {total_rows} 行")
 ```