Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support table component in streamlit #607

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions examples/streamlit_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def get_pyg_renderer() -> "StreamlitRenderer":

st.subheader("Display Explore UI")

tab1, tab2, tab3, tab4 = st.tabs(
["graphic walker", "data profiling", "graphic renderer", "pure chart"]
tab1, tab2, tab3, tab4, tab5 = st.tabs(
["graphic walker", "data profiling", "graphic renderer", "pure chart", "table"]
)

with tab1:
Expand All @@ -41,3 +41,6 @@ def get_pyg_renderer() -> "StreamlitRenderer":
renderer.chart(0)
st.markdown("### registered per day")
renderer.chart(1)

with tab5:
renderer.table()
2 changes: 1 addition & 1 deletion pygwalker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pygwalker.services.global_var import GlobalVarManager
from pygwalker.services.kaggle import show_tips_user_kaggle as __show_tips_user_kaggle

__version__ = "0.4.9.5"
__version__ = "0.4.9.6"
__hash__ = __rand_str()

from pygwalker.api.jupyter import walk, render, table
Expand Down
2 changes: 1 addition & 1 deletion pygwalker/api/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,4 @@ def table(
**kwargs
)

walker.display_on_jupyter_use_widgets("800px")
walker.display_on_jupyter_use_widgets(iframe_height="800px")
13 changes: 11 additions & 2 deletions pygwalker/api/streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,20 @@ def chart(
def render_pure_chart(self, *args, **kwargs):
return self.chart(*args, **kwargs)

def table(
self,
*,
key: str = "table",
):
"""Render pure table UI"""
key = f"{self.walker.gid}-{key}"
return self._component(key=key, mode="table")

def _component(
self,
*,
key: str,
mode: Literal["explore", "renderer", "filter_renderer"],
mode: Literal["explore", "renderer", "filter_renderer", "table"],
vis_spec: Optional[List[Dict[str, Any]]] = None,
**kwargs: Dict[str, Any]
):
Expand Down Expand Up @@ -283,7 +292,7 @@ def get_streamlit_html(
show_cloud_tool: Optional[bool] = None,
spec_io_mode: ISpecIOMode = "r",
kanaries_api_key: str = "",
mode: Literal["explore", "filter_renderer"] = "explore",
mode: Literal["explore", "filter_renderer", "table"] = "explore",
default_tab: Literal["data", "vis"] = "vis",
**kwargs
) -> str:
Expand Down
Loading