render_altair()

Render a DataFrame with a VISUALISE spec to an Altair chart.

Usage

Source

render_altair(
    df,
    viz,
    *,
    validate=False,
    height=None,
    width=None,
    **kwargs,
)

Parameters

df: IntoFrame

Data to visualize. Accepts polars, pandas, or any narwhals-compatible DataFrame. LazyFrames are collected automatically.

viz: str

VISUALISE spec string (e.g., “VISUALISE x, y DRAW point”)

validate: bool = False

Whether to validate the spec against the Vega-Lite schema.

height: int | None = None

Chart height in pixels. When None (the default), the height produced by ggsql is used as-is.

width: int | None = None

Chart width in pixels. When None (the default), the width produced by ggsql is used as-is.

**kwargs: Any
Additional keyword arguments passed to altair.Chart.from_json().

Returns

AltairChart
An Altair chart object (Chart, LayerChart, FacetChart, etc.).