vega-lite icon indicating copy to clipboard operation
vega-lite copied to clipboard

Duplicate scale or projection name error when using non-ASCII characters in repeat

Open blanchco opened this issue 11 months ago • 1 comments

Bug Description

We encountered an issue when using multiple non-ASCII characters (e.g., greek letters) in the repeat function in Vega-Lite. The error shown is:

This seems to happen when the encoding generates internal names that are not sufficiently distinct, likely due to normalization or stripping of special characters.

Here is an example where I am selecting ["γ", "β"] two non-ascii characters in the repeat. The error show is: Duplicate scale or projection name: "child__row__column___x"

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "repeat": {"row": ["γ", "β"], "column": ["γ", "β"]},
  "data": {
    "values": [
      {
        "β": 0.8,
        "γ": 0.3,
        "S": 0.3
      },
      {
        "β": 0.6,
        "γ": 0.2,
        "S": 0.2
      },
      {
        "β": 0.7,
        "γ": 0.1,
        "S": 0.1
      }
    ]
  },
  "spec": {
    "width": 150,
    "height": 150,
    "mark": {"type": "point", "filled": true},
    "encoding": {
      "x": {
        "field": {"repeat": "column"},
        "type": "quantitative"
      },
      "y": {
        "field": {"repeat": "row"},
        "type": "quantitative",
        
      },
      "size": {"value": 80}
    }
  }
}
Image

Expected

Here is a working example which is showing as expected (I am using a non ascii character with an ascii one) "γ", "S".
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "repeat": {"row": ["γ", "S"], "column": ["γ", "S"]},
  "data": {
    "values": [
      {
        "β": 0.8,
        "γ": 0.3,
        "S": 0.3
      },
      {
        "β": 0.6,
        "γ": 0.2,
        "S": 0.2
      },
      {
        "β": 0.7,
        "γ": 0.1,
        "S": 0.1
      }
    ]
  },
  "spec": {
    "width": 150,
    "height": 150,
    "mark": {"type": "point", "filled": true},
    "encoding": {
      "x": {
        "field": {"repeat": "column"},
        "type": "quantitative"
      },
      "y": {
        "field": {"repeat": "row"},
        "type": "quantitative",
        
      },
      "size": {"value": 80}
    }
  }
}
Image

Checklist

  • [x] I checked for duplicate issues.

blanchco avatar May 27 '25 19:05 blanchco

Yeah, we replace non ascii characters with _ to get around some issues. That's clearly too simplistic of a solution here. Happy to review a pull request to improve this.

domoritz avatar Jun 06 '25 10:06 domoritz