Html API
Users can render the UI of Graphic Walker onto any application that supports rendering HTML.
However, the current approach only supports front-end computation and is not suitable for use with larger datasets.
to_html
import pygwalker as pyg
html_str = pyg.to_html(df)
Parameters
Parameter | Type | Default | Description |
---|---|---|---|
dataset | DataFrame | - | The dataframe to be used. refer Dataset Of Walker. |
gid | Union[int, str] | None | ID for the GraphicWalker container div, formatted as 'gwalker-{gid}'. If gid is None, it will be automatically generated. |
field_specs | Optional[Dict[str, FieldSpec]] | None | Specifications of fields. Will be automatically inferred from dataset if not specified. |
theme_key | Literal['vega', 'g2'] | 'g2' | Theme type for the GraphicWalker. |
dark | Literal['media', 'light', 'dark'] | 'media' | Theme setting. 'media' will auto-detect the OS theme. |
spec | str | "" | Chart configuration data. Can be a configuration ID, JSON, or remote file URL. |
default_tab | Literal["data", "vis"] | "vis" | default tab to show. Default to "vis". |
**kwargs | Any | - | Additional keyword arguments. |
Example
export html file
import pandas as pd
import pygwalker as pyg
df = pd.read_csv('data.csv')
with open("demo.html", "w", encoding="utf-8") as f:
f.write(pyg.to_html(df))