Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for VegaFusion data transformer in Vega pane #7171

Open
jurriaanpro opened this issue Aug 20, 2024 · 0 comments
Open

Support for VegaFusion data transformer in Vega pane #7171

jurriaanpro opened this issue Aug 20, 2024 · 0 comments
Labels
type: enhancement Minor feature or improvement to an existing feature
Milestone

Comments

@jurriaanpro
Copy link

Is your feature request related to a problem? Please describe.

https://panel.holoviz.org/reference/panes/Vega.html#altair

I'm trying to plot an altair chart with a large amount of datapoints which makes it throw a MaxRowsError.

    raise MaxRowsError(
altair.utils.data.MaxRowsError: The number of rows in your dataset is greater than the maximum allowed (20000).

Try enabling the VegaFusion data transformer which raises this limit by pre-evaluating data
transformations in Python.
    >> import altair as alt
    >> alt.data_transformers.enable("vegafusion")

Or, see https://altair-viz.github.io/user_guide/large_datasets.html for additional information
on how to plot large datasets.

Following the URL in the error I have installed and enabled the vegafusion data transformer, but then I run into

File "<snip>/.venv/lib/python3.11/site-packages/panel/pane/vega.py", line 79, in _get_schema_version
    schema = obj.to_dict().get('$schema', '')
             ^^^^^^^^^^^^^
  File "<snip>/.venv/lib/python3.11/site-packages/altair/vegalite/v5/api.py", line 984, in to_dict
    raise ValueError(
ValueError: When the "vegafusion" data transformer is enabled, the 
to_dict() and to_json() chart methods must be called with format="vega". 
For example: 
    >>> chart.to_dict(format="vega")
    >>> chart.to_json(format="vega")

Describe the solution you'd like

I would like the Vega widget in Panel to detect whether the VegaFusion data transformer is enabled, and pass the required format="vega" parameter to the to_dict calls.

https://github.com/holoviz/panel/blob/main/panel/pane/vega.py#L82
https://github.com/holoviz/panel/blob/main/panel/pane/vega.py#L127

This might be used as inspiration: https://github.com/vega/altair/blob/main/altair/utils/_vegafusion_data.py#L282,L287

Describe alternatives you've considered

Reducing the amount of datapoints is a possibility, but reduces usability.

@philippjfr philippjfr added the type: enhancement Minor feature or improvement to an existing feature label Aug 20, 2024
@philippjfr philippjfr added this to the v1.6.0 milestone Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants