-
Notifications
You must be signed in to change notification settings - Fork 624
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
repeat operator with defined width and height does not accept layer #8523
Comments
As you mentioned in the title, when you remove "RepeatSpec": {
"anyOf": [
{
"$ref": "#/definitions/NonLayerRepeatSpec"
},
{
"$ref": "#/definitions/LayerRepeatSpec"
}
]
} I'm wondering if this example somehow does not fit both definitions and then shows the error based on matching the spec against "NonLayerRepeatSpec" where the error then is that "layer" is not allowed. The following warning suggests this as well:
-> Here it should not match against Would you know any way in the Vega Editor (or other tool) to learn more about the warnings? It would be great to know why it doesn't match the layered one. I'll try to validate it in Python. |
I used python-jsonschema to validate the specs against "spec": {
"anyOf": [
{
"$ref": "#/definitions/LayerSpec"
},
{
"$ref": "#/definitions/UnitSpec"
}
],
"description": "A specification of the view that gets repeated."
}, Validating the specs against I think this means that there is currently no schema-conform way to specify height and width for a layered repeat chart. I don't know enough about Vega-Lite to solve this but I hope this gives someone else a good start to adjust the schema if necessary. AppendixFor reference, code I used to validate the spec in Python: import json
import altair as alt
import jsonschema
import jsonschema.validators
import jsonschema.exceptions
def create_validator(schema, rootschema=None):
if rootschema is not None:
validator_cls = jsonschema.validators.validator_for(rootschema)
resolver = jsonschema.RefResolver.from_schema(rootschema)
else:
validator_cls = jsonschema.validators.validator_for(schema)
# No resolver is necessary if the schema is already the full schema
resolver = None
validator_kwargs = {"resolver": resolver}
if hasattr(validator_cls, "FORMAT_CHECKER"):
validator_kwargs["format_checker"] = validator_cls.FORMAT_CHECKER
validator = validator_cls(schema, **validator_kwargs)
return validator
spec_json = """{
"repeat": {
"layer": ["US_Gross", "Worldwide_Gross"],
"column": ["IMDB_Rating", "Rotten_Tomatoes_Rating"]
},
"spec": {
"width": 200,
"height": 130,
"data": {
"url": "https://cdn.jsdelivr.net/npm/[email protected]/data/movies.json"
},
"mark": "line",
"encoding": {
"color": {"datum": {"repeat": "layer"}},
"x": {"bin": true, "field": {"repeat": "column"}},
"y": {
"aggregate": "mean",
"field": {"repeat": "layer"},
"title": "Mean of US and Worldwide Gross"
}
}
}
}"""
spec = json.loads(spec_json)
layered_schema = {"$ref": "#/definitions/LayerRepeatSpec"}
# non_layered_schema = {"$ref": "#/definitions/NonLayerRepeatSpec"}
validator = create_validator(layered_schema, alt.Chart()._rootschema)
errors = list(validator.iter_errors(spec)) Travers the error hierarchy as I described in vega/altair#2842. Access |
This is super helpful @binste! One thing I noticed is that if you use I have an idea of trying to use Edit: This is the change I tried to make: next...ChristopherDavisUCI:vega-lite:cd/allow-size My understanding is that running |
Interesting! Just checked the v4 schema and indeed, in there the Thank you @ChristopherDavisUCI for trying to rebuild the schema! I can't dedicate enough time right now to get up and running myself with vega-lite but really appreciate that you dig into this :) Hopefully a vega-lite contributor can jump in as well and help out. |
Thanks @binste! I had another look and think I was able to find one possible solution to this issue in #8676. The main difference is allowing @mattijn Would it make sense to delete the |
Nope, the Rendering issues are still tracked by error and warning messages. You'll have to build Vega-Editor linked to your updated Vega-Lite bundle plus new VL-schema. I think it is a quite complicated proces before we can test and play with your updated vl-schema. I'm not sure how and if this can be simplified. Maybe the editor can have a menu-setting where manually another VL-bundle/schema can be specified. |
Hi @mattijn, thanks for looking at it! I am able to get your spec in #8523 (comment) to work locally on my computer, but only if I change Here is what it looks like locally with Here is what it looks like with |
This spec Open the Chart in the Vega Editor:
Renders correctly. But officially the
layer
cannot be defined, since the schema does not accept it:Which is problematic for Altair-alike software
The text was updated successfully, but these errors were encountered: