Unrecognized scale name: "child_layer_0_y" error for facet dual charts

{
    "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
    "data":{
        "url": "data/cars.json"
    },
    "facet":{
        "column": {
            "field":"Origin",
            "type": "nominal"
        }
    },
    "spec":{
        "layer": [
            {
                "mark": {
                    "type": "bar",
                    "clip": true,
                    "tooltip": true
                },
                "encoding": {
                    
                    "x": {
                        "field": "Cylinders",
                        "type": "ordinal"
                    },
                    "y": {
                        "field": "Acceleration",
                        "type": "quantitative",
                        "aggregate":"average",
                        "axis": {
                            "title": "Acceleration",
                            "orient": "left"
                        }
                    },
                    "color": {
                        "field": "Cylinders",
                        "type": "nominal",
                        "legend":null
                    }
                }
            },
            {
                "mark": {
                    "type": "line",
                    "clip": true,
                    "color":"#ffde25",
                    "tooltip": true
                },
                "encoding": {
                    "x": {
                        "field": "Cylinders",
                        "type": "ordinal"
                    },
                    "y": {
                        "field": "Weight_in_lbs",
                        "type": "quantitative",
                        "aggregate":"average",
                        "axis": {
                            "title": "Weight (lbs)",
                            "orient": "right"
                        }
                    }
                    
                }
            }
        ],
        "resolve": {
            "scale": {"y": "independent"}
        }
    }
    

}

output :

{
    "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
    "data":{
        "url": "data/cars.json"
    },
    "facet":{
        "column": {
            "field":"Origin",
            "type": "nominal"
        }
    },
    "spec":{
        "layer": [
            {
                "mark": {
                    "type": "bar",
                    "clip": true,
                    "tooltip": true
                },
                "encoding": {
                    
                    "x": {
                        "field": "Cylinders",
                        "type": "ordinal"
                    },
                    "y": {
                        "field": "Acceleration",
                        "type": "quantitative",
                        "aggregate":"average",
                        "axis": {
                            "title": "Acceleration",
                            "orient": "left"
                        }
                    },
                    "color": {
                        "field": "Cylinders",
                        "type": "nominal",
                        "legend":null
                    }
                }
            },
            {
                "mark": {
                    "type": "line",
                    "clip": true,
                    "color":"#ffde25",
                    "tooltip": true
                },
                "encoding": {
                    "x": {
                        "field": "Cylinders",
                        "type": "ordinal"
                    },
                    "y": {
                        "field": "Weight_in_lbs",
                        "type": "quantitative",
                        "aggregate":"average",
                        "axis": {
                            "title": "Weight (lbs)",
                            "orient": "right"
                        }
                    }
                    
                }
            }
        ],
        "resolve": {
            "scale": {"y": "independent"}
        }
    },
    "resolve": {
        "scale": {"y": "shared"},
        "axis": {"y": "independent"}
    }

}

if we add one more resolve, it gives this output

image

I want to have both the Y axes shared for all 3 graphs, instead of having 2 individual Y axis for each graph. May I know how to do it ?

This seems like a pure vega-lite question, and is perhaps best answered in vega community forum - sorry, I'm not familiar with where those might be.

Guessing though, that this involves making scale/axis resolve/shared differently that you currently have at the end of your sample:

        "resolve": {
            "scale": {"y": "independent"}
        }
    },
    "resolve": {
        "scale": {"y": "shared"},
        "axis": {"y": "independent"}
    }

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.