Chart State#

The Chart State workflow can be used to support interactive charts with transforms that are updated interactively. For example, for a chart that implements crossfiltering the filter transform must be re-evaluated repeatedly against the input dataset.

This is the foundation of Vega-Altair’s JupyterChart when combined with the "vegafusion" data transformer.

Python#

VegaFusionRuntime.new_chart_state(spec: dict[str, Any] | str, local_tz: str | None = None, default_input_tz: str | None = None, row_limit: int | None = None, inline_datasets: dict[str, Any] | None = None) ChartState#

Construct new ChartState object.

Parameters:
  • spec – A Vega specification dict or JSON string.

  • local_tz – Name of timezone to be considered local. E.g. ‘America/New_York’. Defaults to the value of vf.get_local_tz(), which defaults to the system timezone if one can be determined.

  • default_input_tz – Name of timezone (e.g. ‘America/New_York’) that naive datetime strings should be interpreted in. Defaults to local_tz.

  • row_limit – Maximum number of dataset rows to include in the returned datasets. If exceeded, datasets will be truncated to this number of rows and a RowLimitExceeded warning will be included in the ChartState’s warnings list.

  • inline_datasets – A dict from dataset names to pandas DataFrames or pyarrow Tables. Inline datasets may be referenced by the input specification using the following url syntax ‘vegafusion+dataset://{dataset_name}’ or ‘table://{dataset_name}’.

Returns:

ChartState

Example: See chart_state.py for a complete example.

Rust#

See chart_state.rs for a complete example.