vega / vegafusion

Serverside scaling for Vega and Altair visualizations
https://vegafusion.io
BSD 3-Clause "New" or "Revised" License
317 stars 17 forks source link

Unrecognized signal name when using a different dataframe inside a concatenated and layered chart where one has a parameter #382

Closed joelostblom closed 1 year ago

joelostblom commented 1 year ago

I found another one! The spec below works with the default transformer but vegafusion throws Javascript Error: Unrecognized signal name: "concat_1_layer_0_bin_maxbins_20_mean_price_bins". I think this is related to how the names are constructed when a parameter (such as maxbins is used) with a different dataframe inside a concatenated and layered chart with a shared scale. I wasn't able to break it down further but here is the spec with comments on which changes makes it work.

df = pd.DataFrame({
    'replicate': [0, 1],
    'mean_price': [166, 169]
})

boot_est_dist = alt.Chart(df).mark_bar().encode(
    x=alt.X("mean_price").bin(maxbins=20),  # Removing maxbins works
    y=alt.Y("count()")
)

alt.vconcat(
    boot_est_dist,
    alt.layer(
        boot_est_dist,
        alt.Chart(df.copy()).mark_rule().encode(x='mean_price')  # Using `df` instead of `df.copy` works
#        alt.Chart(df.copy()).mark_rule().encode(alt.X('mean_price').bin(maxbins=20))  # Replacing the row above with this works as well

    )
).resolve_scale(  # Removing `resolve_scale` works
    x='shared'
)

And if you wonder how come I'm reporting so many of these today it's because we are trying to transitioning a textbook and corresponding set of assignments to use vegafusion so I'm running it through a lot of examples.

jonmmease commented 1 year ago

Wow, you're on a roll! The VegaFusion data transformer needs to be something you can turn on and not worry about, so these are exactly the kinds of reports we need in order to get there.

Thanks for giving VegaFusion a try with your teaching material!