Closed longxiaofei closed 6 months ago
to_chart_html
API Reference
def to_chart_html( dataset: Union[DataFrame, Connector, str], spec: Dict[str, Any], *, spec_type: Literal["graphic-walker", "vega"] = "graphic-walker", theme_key: Literal['vega', 'g2'] = 'g2', dark: Literal['media', 'light', 'dark'] = 'media', ) -> str: """ Generate HTML code of a chart by graphic-walker or vega spec. Args: - dataset (pl.DataFrame | pd.DataFrame | Connector, optional): dataset. - spec (Dict[str, Any]): chart config data. Kargs: - spec_type (Literal["graphic-walker", "vega"]): type of spec. - theme_key ('vega' | 'g2'): theme type. - dark ('media' | 'light' | 'dark'): 'media': auto detect OS theme. """ pass
Example
from pygwalker.api.html import to_chart_html from IPython.display import display, HTML html = to_chart_html( df, { "mark": "bar", "encoding": { "x": {"field": "season"}, "y": {"field": "casual", "aggregate": "sum"}, "color": {"field": "holiday"}, } }, spec_type="vega" ) display(HTML(html))
new api
to_chart_html
API Reference
Example