vega-lite
vega-lite copied to clipboard
Named repeat specs cause runtime error: "Duplicate data set name"
Assigning a name (e.g., "Some Name") to a repeated spec will generate a vega spec containing children with non-unique names, thus raising an error "Duplicate data set name: "Some_Name_marks". This can be reproduced in the vega-lite editor by loading "Multi Series Line Chart with Halo Stroke" (line_color_halo.vl.json) and setting the repeated spec property: "name": "Some Name"
A simpler sample spec that shows this error:
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.13.1.json",
"data": {"values": [{}] },
"repeat": {
"layer": ["A","Z"]
},
"spec": {
"layer": [{
"name": "LAYERNAME",
"mark": {"type": "point"}
}
]
}
}
This generates the following vega spec that has duplicate instances of "LAYERNAME_marks":
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"width": 20,
"height": 20,
"style": "cell",
"data": [{"name": "source_0", "values": [{}]}],
"marks": [
{
"name": "LAYERNAME_marks",
"type": "symbol",
"style": ["point"],
"from": {"data": "source_0"},
"encode": {
"update": {
"opacity": {"value": 0.7},
"fill": {"value": "transparent"},
"stroke": {"value": "#4c78a8"},
"ariaRoleDescription": {"value": "point"},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5}
}
}
},
{
"name": "LAYERNAME_marks",
"type": "symbol",
"style": ["point"],
"from": {"data": "source_0"},
"encode": {
"update": {
"opacity": {"value": 0.7},
"fill": {"value": "transparent"},
"stroke": {"value": "#4c78a8"},
"ariaRoleDescription": {"value": "point"},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5}
}
}
}
]
}
The error in the console is:
Error: Duplicate data set name: "LAYERNAME_marks"
(anonymous function) — error.js:2
(anonymous function) — Scope.js:436
(anonymous function) — mark.js:130
forEach
(anonymous function) — scope.js:38
b — view.js:65
(anonymous function) — parse.js:12
initView — renderer.tsx:134
componentDidUpdate — renderer.tsx:257
os — react-dom.production.min.js:212:481
fu — react-dom.production.min.js:255:474
fu
(anonymous function) — scheduler.production.min.js:20:238
hu — react-dom.production.min.js:249:218
Js — react-dom.production.min.js:241
Js
(anonymous function) — react-dom.production.min.js:123:348
(anonymous function) — scheduler.production.min.js:20:238
Ki — react-dom.production.min.js:123:306
qi — react-dom.production.min.js:123:247
eu — react-dom.production.min.js:241:156
notify — Subscription.js:19
(anonymous function) — Subscription.js:92
(anonymous function) — Subscription.js:97
[native code]
m — redux.js:221
updateSpec — renderer.tsx:244
handleEditorChange — renderer.tsx:160:84
handleEditorChange
i — debounce.js:5
https://vega.github.io/schema/vega-lite/v4.13.1json
Perhaps repeat layer names could be additionally suffixed with the index or identifier of the child layer, so the layers in the above spec would generate distinct names like: "LAYERNAME_repeat_1_marks" and "LAYERNAME_repeat_2_marks"?
Might this be related to https://github.com/vega/vega-lite/issues/4274?
I think the issue may just be in the normalizer. It probably doesn't include the layered field in the name. Can you send a pull request to fix it?
This is the normalized spec.
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.13.1.json",
"data": {"values": [{}]},
"layer": [
{
"layer": [
{"name": "LAYERNAME", "mark": {"type": "point"}, "encoding": {}}
],
"name": "child__layer_A"
},
{
"layer": [
{"name": "LAYERNAME", "mark": {"type": "point"}, "encoding": {}}
],
"name": "child__layer_Z"
}
]
}
I think people may need control over the children's names. However, since repeat can only be used for fields right now, I don't think we have a good solution.
I'm demoting this to P4 since it's an uncommon use case.
I think it's already fixed in v5.16.3