Skip to content
PYGWALKER
API 참조
HTML Exports

PyGWalker HTML API Guide

PyGWalker allows you to render the Graphic Walker UI in any application that supports HTML rendering. This guide explains how to use the HTML API effectively.

Important Note

The current HTML API is designed for front-end computation only. It may not be suitable for large datasets due to performance limitations.

Using to_html()

The to_html() function is the primary method for generating HTML output from your DataFrame.

Basic Usage

import pygwalker as pyg
import pandas as pd
 
df = pd.read_csv('data.csv')
html_str = pyg.to_html(df)

Function Parameters

ParameterTypeDefaultDescription
datasetDataFrame-The input DataFrame. See Dataset Of Walker for more details.
gidUnion[int, str]NoneID for the GraphicWalker container div. Format: 'gwalker-{gid}'. Auto-generated if None.
field_specsOptional[Dict[str, FieldSpec]]NoneField specifications. Automatically inferred from dataset if not specified.
theme_keyLiteral['vega', 'g2']'g2'Theme type for GraphicWalker.
appearanceLiteral['media', 'light', 'dark']'media'Theme setting. 'media' auto-detects the OS theme.
specstr""Chart configuration data. Can be a configuration ID, JSON, or remote file URL.
default_tabLiteral["data", "vis"]"vis"Default tab to show when the UI loads.
**kwargsAny-Additional keyword arguments.

Examples

Exporting to an HTML File

You can save the generated HTML to a file for later use or sharing:

import pandas as pd
import pygwalker as pyg
 
df = pd.read_csv('data.csv')
 
with open("pygwalker_demo.html", "w", encoding="utf-8") as f:
    f.write(pyg.to_html(df))

Using PyGWalker with Shiny

PyGWalker can be integrated into Shiny applications. For a detailed guide and example, refer to our Shiny integration tutorial.

Best Practices

  1. Performance Considerations: Be mindful of the dataset size when using the HTML API, as it processes data on the client-side.
  2. Customization: Utilize the field_specs parameter to fine-tune how your data is interpreted and displayed.
  3. Theming: Experiment with different theme_key and appearance settings to match your application's look and feel.
  4. Integration: When integrating with web frameworks like Shiny, ensure you handle the HTML output appropriately within your application's structure.

For more advanced usage and integration examples, please refer to the PyGWalker documentation.

on shiny