Skip to content

resolve_scaled followed by facet gives an inscrutable error Unrecognized scale name: "child_layer_0_y" #9612

@rambip

Description

@rambip

Bug Description

Goal: create a layered chart, facet it, and resolve axis independently.
If the resolve_scale is not at the right place, it will fail with an error that gives no clue what the problem is.

Note that I used vega-altair to generate the expression, but I think that both altair and vega-lite have a part of responsability in the issue.

First attempt:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.20.1.json",
  "columns": 6,
  "data": {
    "values": [
      {"country": 0, "v1": 100, "v2": 4, "date": 0},
      {"country": 0, "v1": 200, "v2": 7, "date": 1},
      {"country": 0, "v1": 300, "v2": 9, "date": 2},
      {"country": 1, "v1": 400, "v2": 6, "date": 0},
      {"country": 1, "v1": 500, "v2": 7, "date": 1},
      {"country": 1, "v1": 600, "v2": 5, "date": 2}
    ]
  },
  "facet": {
    "field": "country",
    "type": "nominal"
  },
  "spec": {
    "layer": [
      {
        "encoding": {
          "x": {
            "field": "date",
            "type": "temporal"
          },
          "y": {
            "field": "v1",
            "type": "quantitative"
          }
        },
        "mark": {
          "type": "line",
          "stroke": "red",
        }
      },
      {
        "encoding": {
          "x": {
            "field": "date",
            "type": "temporal"
          },
          "y": {
            "field": "v2",
            "type": "quantitative"
          }
        },
        "mark": {
          "type": "line"
        }
      }
    ],
    "resolve": {
      "scale": {
        "y": "independent"
      }
    }
  }
}

I get the error:

Unrecognized scale name: "child_layer_0_y"

Second attempt. The difference is that resolve is specified at the root and not in the layers.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.20.1.json",
  "columns": 6,
  "data": {
    "values": [
      {"country": 0, "v1": 100, "v2": 4, "date": 0},
      {"country": 0, "v1": 200, "v2": 7, "date": 1},
      {"country": 0, "v1": 300, "v2": 9, "date": 2},
      {"country": 1, "v1": 400, "v2": 6, "date": 0},
      {"country": 1, "v1": 500, "v2": 7, "date": 1},
      {"country": 1, "v1": 600, "v2": 5, "date": 2}
    ]
  },
  "facet": {
    "field": "country",
    "type": "nominal"
  },
  "resolve": {
      "scale": {
        "y": "independent"
      }
    },
  "spec": {
    "layer": [
      {
        "encoding": {
          "x": {
            "field": "date",
            "type": "temporal"
          },
          "y": {
            "field": "v1",
            "type": "quantitative"
          }
        },
        "mark": {
          "type": "line",
          "stroke": "red",
        }
      },
      {
        "encoding": {
          "x": {
            "field": "date",
            "type": "temporal"
          },
          "y": {
            "field": "v2",
            "type": "quantitative"
          }
        },
        "mark": {
          "type": "line"
        }
      }
    ],
  }
}

This time, it did not return an error:

Image

Expected behaviour

The first attempt should either work, or either indicate that resolve is not set in the right place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions