Kanaries / pygwalker

PyGWalker: Turn your pandas dataframe into an interactive UI for visual analysis
https://kanaries.net/pygwalker
Apache License 2.0
12.85k stars 664 forks source link

Use Streamlit's officially recommended method to render Pygwalker UI #531

Open longxiaofei opened 5 months ago

longxiaofei commented 5 months ago

Use Streamlit's officially recommended method to render Pygwalker UI, so the following changes have been made:

1.Temporary delete the Exploer button under pure chart

Under the new rendering method, Pygwalker needs to complete the Request-Response communication through rerun, and retun will lose the state of modal.

old:

image

new:

image

2. Modify the parameters of the rendering method

The new API will delete width, height, scrolling parameters, and when the user needs to render the same component multiple times, different keys need to be used, which will be consistent with the parameters of the official streamlit component.

old:

def viewer(
    self,
    width: Optional[int] = None,
    height: int = 1010,
    scrolling: bool = False,
) -> "DeltaGenerator":
    """Render filter renderer UI"""
    pass

def explorer(
    self,
    width: Optional[int] = None,
    height: int = 1010,
    scrolling: bool = False,
    default_tab: Literal["data", "vis"] = "vis"
) -> "DeltaGenerator":
    """Render explore UI(it can drag and drop fields)"""
    pass

def chart(
    self,
    index: int,
    width: Optional[int] = None,
    height: Optional[int] = None,
    scrolling: bool = False,
    pre_filters: Optional[List[PreFilter]] = None,
) -> "DeltaGenerator":
    pass

new:

def viewer(
    self,
    *,
    key: str = "viewer",
    size: Optional[Tuple[int, int]] = None
):
    """Render filter renderer UI"""
    pass

def explorer(
    self,
    *,
    key: str = "explorer",
    default_tab: Literal["data", "vis"] = "vis"
):
    """Render explore UI(it can drag and drop fields)"""
    pass

def chart(
    self,
    index: int,
    *,
    key: str = "chart",
    size: Optional[Tuple[int, int]] = None,
    pre_filters: Optional[List[PreFilter]] = None,
):
    pass

beta version: pip install pygwalker==0.4.9a3