vega-lite: 'Duplicate signal name' error for shared param across views

When using repeat to layer multiple fields, one is unable to use hover to implement any interaction. An error is shown Error: Duplicate signal name: "sel1_tuple"

See https://observablehq.com/@cjnygard/vega-lite-bug for implementation (you can play with the flags in the plot4() function to true different combinations of hover, repeat, and facet. It’s clearly related to the repeat, as shown in the below generated JSON (generated from the page above).

{
  "facet": {
    "column": {
      "field": "name"
    }
  },
  "spec": {
    "repeat": {
      "layer": [
//        "y1",    // Uncomment this to trigger bug
        "y2"
      ]
    },
    "spec": {
      "layer": [
        {
          "mark": {
            "type": "line",
            "interpolate": "monotone"
          },
          "encoding": {
            "x": {
              "field": "x",
              "type": "quantitative"
            },
            "y": {
              "field": {
                "repeat": "layer"
              },
              "type": "quantitative"
            },
            "color": {
              "datum": {
                "repeat": "layer"
              },
              "legend": {
                "title": "Legend"
              }
            }
          }
        },
        {
          "mark": {
            "type": "circle"
          },
          "encoding": {
            "x": {
              "field": "x",
              "type": "quantitative"
            },
            "y": {
              "field": {
                "repeat": "layer"
              },
              "type": "quantitative"
            },
            "color": {
              "datum": {
                "repeat": "layer"
              },
              "legend": {
                "title": "Legend"
              }
            },
            "opacity": {
              "condition": {
                "test": {
                  "selection": "sel1"
                },
                "value": 1
              },
              "value": 0
            }
          },
          "selection": {
            "sel1": {
              "type": "single",
              "encodings": [
                "y"
              ],
              "on": "mouseover",
              "nearest": true,
              "empty": "none"
            }
          }
        }
      ],
      "width": 350,
      "height": 200
    }
  },
  "data": {
    "values": [
      {
        "name": "foo",
        "x": 1,
        "y1": 1,
        "y2": 21
      },
      {
        "name": "foo",
        "x": 2,
        "y1": 2,
        "y2": 22
      },
      {
        "name": "foo",
        "x": 3,
        "y1": 3,
        "y2": 23
      },
      {
        "name": "bar",
        "x": 4,
        "y1": 10,
        "y2": 31
      },
      {
        "name": "bar",
        "x": 5,
        "y1": 11,
        "y2": 32
      },
      {
        "name": "bar",
        "x": 6,
        "y1": 12,
        "y2": 33
      }
    ]
  }
}

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

The reply from @kanitw with top-level defined params and a layered chart can be resolved using views within params in combination with a name definition on a single chart object within the layer: Open the Chart in the Vega Editor

Status of a chart with a:

  1. repeat operator & params within the spec: Open the Chart in the Vega Editor
  2. repeat operator & params top-level: Open the Chart in the Vega Editor
  3. repeat operator & params top-level using a views attribute and name: Open the Chart in the Vega Editor
  4. repeat operator on a layer & params on the first object within layer: Open the Chart in the Vega Editor (slow!)
  5. repeat operator on a layer & params top-level: Open the Chart in the Vega Editor
  6. repeat operator on a layer & params top-level using a views attribute & name on the first object within layer: Open the Chart in the Vega Editor (slow!)

The following issue is also related to the repeat operator on a layer with params top-level using a views attribute & name on the first object within layer: https://github.com/vega/vega-lite/issues/8348, but there is still another issue with brush not resolving properly.

I’m able to replicate this when we add params to top-level for multi-view charts

{

  "params": [{"name": "selection", "select": {"type": "point"}}],
  "data": {"url": "data/cars.json"},
  "layer": [
    {
      "mark": {"type": "point", "filled": true},
      "encoding": {
        "x": {"field": "Horsepower", "type": "quantitative"},
        "y": {"field": "Acceleration", "type": "quantitative"}
      }
    },
    {
      "transform": [{"filter": {"param": "selection"}}],
      "mark": {"type": "point", "filled": true},
      "encoding": {
        "x": {"field": "Horsepower", "type": "quantitative"},
        "y": {"field": "Acceleration", "type": "quantitative"}
      }
    }
  ]
}