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

resolve_scale on individual chart errors with unhelpful error message when faceted or layered #3502

Open
joelostblom opened this issue Jul 25, 2024 · 0 comments
Labels

Comments

@joelostblom
Copy link
Contributor

joelostblom commented Jul 25, 2024

What happened?

When a single chart uses resolve_scale, the chart can be displayed on its own or together in a concat, but not inside a layer or with .facet. The error message is not helpful in the latter two cases:

import altair as alt
from vega_datasets import data

iris = data.iris().sample(5, random_state=239)

points = alt.Chart(iris).mark_point().encode(
    x='petalLength',
    y='petalWidth',
    color='species'
).resolve_scale(color='independent')

points # Works
alt.concat(points) # Works

alt.layer(points)  # Error
SchemaValidationError: `LayerChart` has no parameter named 'mark'

Existing parameter names are:
layer        data          height    projection   usermeta   
autosize     datasets      name      resolve      view       
background   description   padding   title        width      
config       encoding      params    transform               

See the help for `LayerChart` to read the full description of these parameters

And with facet:

points.facet('species:N')  # Error
SchemaValidationError: `Spec` has no parameter named 'mark'

Existing parameter names are:
args   

See the help for `Spec` to read the full description of these parameters

In both cases, underlying specs works in the Vega editor (with slightly different warnings): Faceted chart and Layered Chart

While it doesn't make sense that resolve works for some compound charts but not for others, a minimal fix in Altair would be to improve the error message, so that it is clear for users what is going awry. Something similar to what we have for faceted charts that are then layered, e.g.:

You are trying to facet a chart that contains a resolved scale. Instead, apply facet first and then resolve the scale of the faceted chart.

What would you like to happen instead?

The Vega-Lite code could be updated to allow/disallow resolve for all compound chart types consistently. Ideally it would generate an error when used on single charts, since it does not have any effect when there are not multiple charts to resolve between.

Which version of Altair are you using?

main

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

1 participant