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

params nested in layer not supported #7812

Closed
mattijn opened this issue Nov 18, 2021 · 2 comments · Fixed by #8304
Closed

params nested in layer not supported #7812

mattijn opened this issue Nov 18, 2021 · 2 comments · Fixed by #8304

Comments

@mattijn
Copy link
Contributor

mattijn commented Nov 18, 2021

Raised in vega/altair#2517 (comment)

The params property defined within a layer object is not resolving OK:

{
  "layer": [
    {
      "data": {
        "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/cars.json"
      },
      "mark": "circle",
      "encoding": {
        "x": {"field": "Miles_per_Gallon", "type": "quantitative"},
        "y": {"field": "Horsepower", "type": "quantitative"}
      }
    },
    {
      "params": [
        {
          "name": "variable001",
          "bind": {"input": "range", "max": 50, "min": 0, "step": 1},
          "value": 25
        }
      ],
      "data": {"name": "empty"},
      "mark": {"type": "rule", "size": 2, "strokeDash": [12, 6]},
      "encoding": {
        "x": {"datum": {"expr": "variable001"}, "type": "quantitative"}
      }
    }
  ],
  "$schema": "https://vega.github.io/schema/vega-lite/v5.1.0.json",
  "datasets": {"empty": [{}]}
}

image

Open the Chart in the Vega Editor
But when the same params property is placed on top-level it functions OK:

{
  "params": [
    {
      "name": "variable001",
      "bind": {"input": "range", "max": 50, "min": 0, "step": 1},
      "value": 25
    }
  ],
  "layer": [
    {
      "data": {
        "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/cars.json"
      },
      "mark": "circle",
      "encoding": {
        "x": {"field": "Miles_per_Gallon", "type": "quantitative"},
        "y": {"field": "Horsepower", "type": "quantitative"}
      }
    },
    {
      "data": {"name": "empty"},
      "mark": {"type": "rule", "size": 2, "strokeDash": [12, 6]},
      "encoding": {
        "x": {"datum": {"expr": "variable001"}, "type": "quantitative"}
      }
    }
  ],
  "$schema": "https://vega.github.io/schema/vega-lite/v5.1.0.json",
  "datasets": {"empty": [{}]}
}

image

Open the Chart in the Vega Editor

I can imagine this can be considered a bug on the Vega-Lite side, but not 100% sure.

@arvind
Copy link
Member

arvind commented Jul 20, 2022

Thanks for reporting the issue, @mattijn! As we were discussing in #8230, only selection parameters can be nested within views. Variable parameters can only be defined at the top-level. Our typings were incorrect in this regard. I've made them more precise in #8304.

@vega-org-bot
Copy link
Collaborator

🚀 Issue was released in v5.3.1-next.2 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants