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

Error persists when trying to concat facetted charts although it is fixed in VegaLite #2742

Closed
joelostblom opened this issue Dec 2, 2022 · 5 comments
Labels

Comments

@joelostblom
Copy link
Contributor

joelostblom commented Dec 2, 2022

When I try to concatenate facetted charts with the latest Altair version from master, I am still seeing Javascript Error: Undefined data set name: "scale_concat_1_child_main" although this was fixed in vega/vega-lite#7639. Exporting the spec to json and pasting it in the Vega editor also seems to work fine although the VegaLite version is 5.2.0 in both cases Open the Chart in the Vega Editor

@ChristopherDavisUCI Are you seeing this as well?

Example spec:

import altair as alt
import pandas as pd


df = pd.DataFrame({
    'type': ['coke', 'coke', 'coke', 'pepsi', 'pepsi', 'pepsi'],
    'taste':[90,75,95,85,80,75],
    'sugar':[2,5,1,2,5,1],
})

plot_a = alt.Chart(df).mark_point().encode(
    x = 'sugar',
    y = 'taste',
).facet('type')

plot_a & plot_a
@joelostblom joelostblom added the bug label Dec 2, 2022
@ChristopherDavisUCI
Copy link
Contributor

Hi @joelostblom, Yes, I can confirm that I get the same JavaScript error (and that the produced json does work in the Vega editor. (Also, the to_json method works for this chart even with the default value of to_json(validate=True).) I haven't seen this discrepancy before between the validation and what renders in Jupyter lab, so no idea at the moment.

@mattijn
Copy link
Contributor

mattijn commented Dec 2, 2022

vega/vega-lite#7639 was "officially" released in VL5.4 (but first appeared in VL5.3-next-4).

Altair schema validation & rendering still uses VL5.2 (since altair_viewer is still on VL5.2). But since the schema validation with VL5.2 works with Altair it can be rendered succefully with vl-convert using VL5.3 (and higher, currently only up to VL5.5, not VL5.6):

import altair as alt
import pandas as pd
import vl_convert as vlc
from IPython import display

df = pd.DataFrame({
    'type': ['coke', 'coke', 'coke', 'pepsi', 'pepsi', 'pepsi'],
    'taste':[90,75,95,85,80,75],
    'sugar':[2,5,1,2,5,1],
})

plot_a = alt.Chart(df).mark_point().encode(
    x = 'sugar',
    y = 'taste',
).facet('type')

vl_spec = (plot_a & plot_a).to_json()

png = vlc.vegalite_to_png(vl_spec, vl_version='v5.3')
display.display(display.Image(data=png))

image

Proof that rendering with VL version 'v5.2' result in the same error as within Altair:

png = vlc.vegalite_to_png(vl_spec, vl_version='v5.2')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [65], in <cell line: 1>()
----> 1 png = vlc.vegalite_to_png(vl_spec, vl_version='v5.2')

ValueError: Vega to SVG conversion failed:
Error: Undefined data set name: "scale_concat_1_child_main"

Question is, why it works in the Vega-Editor. It seems that the Vega-Editor validates uses VL5.2 but renders with a higher version? Not the latest either, since features from VL5.6 won't render correctly (axis still go to zero).

I cannot understand anymore what did release at which moment with all these autogenerated next-releases at the VL-repo. Good you opened this: vega/vega-lite#8522.

@joelostblom
Copy link
Contributor Author

Thank you for that thorough investigation! The fact that the vega editor is labeled as version 5.2 but allows for some functionality from later releases to work is indeed confusing. Maybe I'll open an issue there about that too.

@joelostblom
Copy link
Contributor Author

Here is the response I got in vega/vega-lite#8581

The version shown by the editor is the version of Vega loaded. Right now, the editor does not load a different version when the spec specifies a different version.

@joelostblom
Copy link
Contributor Author

I ran into this today and confirming that with the upgrade to VL 5.6 in #2871 this indeed works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants