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 cannot be common to individual Layers. #9387

Open
VikrantRamesh opened this issue Jul 11, 2024 · 0 comments
Open

Params cannot be common to individual Layers. #9387

VikrantRamesh opened this issue Jul 11, 2024 · 0 comments
Labels

Comments

@VikrantRamesh
Copy link

VikrantRamesh commented Jul 11, 2024

Bug Description

I encountered a bug where I cannot place params common to all the layers and modify the opacity with respect to them.
(Open the Chart in the Vega Editor) . Please do let me know if there is a work-around. Find the json below:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {"url": "data/seattle-weather.csv"},
  "width": 500,
  "transform": [
    {
      "calculate": "random() < 0.5 ? 'north' : 'south'",
      "as": "region"
    }
  ],
  "params": [
    {
      "name": "legendSelection",
      "select": {"type": "point", "fields": ["combinedColumn"]},
      "bind": "legend"
    }
  ],
  "layer": [
    {
      // Tab 1
      "layer": [
        {
          "layer": [
            {
              "mark": {"type": "bar"},
              "encoding": {
                "x": {
                  "timeUnit": "month",
                  "field": "date",
                  "type": "ordinal"
                },
                "y": {
                  "aggregate": "sum",
                  "field": "temp_min",
                  "type": "quantitative"
                },
                "color": {"datum": "temp_min"},
                "opacity": {
                  "condition": {
                    "param": "legendSelection",
                    "value": 1
                  },
                  "value": 0.3
                }
              }
            }
          ]
        }
      ]
    },
    {
      // Tab 2
      "layer": [
        {
          "transform": [
            {
              "fold": ["precipitation", "temp_max"],
              "as": ["metric", "value"]
            },
            {
              "calculate": "datum.weather + ' - ' + datum.metric",
              "as": "combinedColumn"
            }
          ],
          "encoding": {
            "color": {"field": "combinedColumn", "type": "nominal"}
          },
          "layer": [
            {
              "transform": [{"filter": "datum.metric == 'precipitation'"}],
              "mark": {
                "type": "line",
                "interpolate": "linear",
                "point": {"fill": "white", "filled": false},
                "strokeDash": [1, 0],
                "tooltip": true
              },
              "encoding": {
                "x": {
                  "timeUnit": "month",
                  "field": "date",
                  "type": "ordinal"
                },
                "y": {
                  "aggregate": "sum",
                  "field": "precipitation",
                  "type": "quantitative"
                },
                "opacity": {
                  "condition": {
                    "param": "legendSelection",
                    "value": 1
                  },
                  "value": 0.3
                }
              }
            },
            {
              "transform": [{"filter": "datum.metric == 'temp_max'"}],
              "mark": {
                "type": "line",
                "interpolate": "linear",
                "point": {"fill": "white", "filled": false},
                "strokeDash": [1, 0],
                "tooltip": true
              },
              "encoding": {
                "x": {
                  "timeUnit": "month",
                  "field": "date",
                  "type": "ordinal"
                },
                "y": {
                  "aggregate": "sum",
                  "field": "temp_max",
                  "type": "quantitative"
                },
                "opacity": {
                  "condition": {
                    "param": "legendSelection",
                    "value": 1
                  },
                  "value": 0.3
                }
              }
            }
          ]
        }
      ]
    }
  ]
}

It throws the following Error:

Duplicate signal name: "legendSelection_tuple"

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