Bug Description
I am trying to show faceted bar charts with the bar name layered on top of them. I have a basic version that works well without the facet, but adding the facet, I get [Error] Undefined data set name: "data_1"
Specification with facet and layers
I can get a (imperfect) result by moving the .spec.encoding.x field down to .spec.layer[0].encoding.x. It does not work if I move it to the next (text) layer, nor if I duplicate it to the next (text) layer.
I tried multiple different variations, but none worked. I also had the same error message, but with another unknown varialbe ([Error] Undefined data set name: "facet"), but I did not save it.
Approximation of the desired result (without the facet, thus splitting vertically on the facet field instead of the group as initially done
Checklist
Feel free to rename the issue with a better name than mine, as I'm not convinced the current one is very helpful.
Bug Description
I am trying to show faceted bar charts with the bar name layered on top of them. I have a basic version that works well without the facet, but adding the facet, I get
[Error] Undefined data set name: "data_1"Specification with facet and layers
{ "$schema": "https://vega.github.io/schema/vega-lite/v6.json", "data": { "values": [ { "group": "2025", "class": "A", "value": 23, "deltaX": 322, "class_color": "#041042" }, { "group": "2025", "class": "B", "value": 21.5, "deltaX": 313, "class_color": "#7c31c0" }, { "group": "2025", "class": "C", "value": 15, "deltaX": 275, "class_color": "#2652bc" } ] }, "transform": [ { "window": [ {"field": "deltaX", "op": "max", "as": "deltaX_max"}, {"field": "value", "op": "max", "as": "value_max"} ], "frame": [null, null] }, { "calculate": "datum.deltaX / datum.deltaX_max * datum.value_max", "as": "value_published" }, {"fold": ["value", "value_published"], "as": ["key", "value"]} ], "facet": { "row": {"field": "key"} }, "spec": { "encoding": { "x": {"field": "value", "type": "quantitative", "title": null}, /* Triggers 'Undefined data set name: "data_1"' */ "y": {"field": "group", "type": "nominal", "title": null}, "yOffset": { "field": "class", "type": "nominal", "sort": {"field": "y", "order": "ascending"} } }, "layer": [ { "mark": {"type": "bar", "tooltip": true}, "encoding": { "color": { "field": "class", "type": "nominal", "scale": {"range": {"field": "class_color"}}, "title": null } } }, { "mark": { "type": "text", "align": "right", "xOffset": -4, "color": "white" }, "encoding": { "text": {"field": "class", "type": "nominal"} } } ] } }I can get a (imperfect) result by moving the
.spec.encoding.xfield down to.spec.layer[0].encoding.x. It does not work if I move it to the next (text) layer, nor if I duplicate it to the next (text) layer.I tried multiple different variations, but none worked. I also had the same error message, but with another unknown varialbe (
[Error] Undefined data set name: "facet"), but I did not save it.Approximation of the desired result (without the facet, thus splitting vertically on the facet field instead of the group as initially done
{ "$schema": "https://vega.github.io/schema/vega-lite/v6.json", "data": { "values": [ { "group": "2025", "class": "A", "value": 23, "deltaX": 322, "class_color": "#041042" }, { "group": "2025", "class": "B", "value": 21.5, "deltaX": 313, "class_color": "#7c31c0" }, { "group": "2025", "class": "C", "value": 15, "deltaX": 275, "class_color": "#2652bc" } ] }, "transform": [ { "window": [ {"field": "deltaX", "op": "max", "as": "deltaX_max"}, {"field": "value", "op": "max", "as": "value_max"} ], "frame": [null, null] }, { "calculate": "datum.deltaX / datum.deltaX_max * datum.value_max", "as": "value_published" }, {"fold": ["value", "value_published"], "as": ["key", "value"]} ], /* Removed faceting */ "encoding": { "x": {"field": "value", "type": "quantitative", "title": null}, "y": {"field": "key" /* Was previously 'group', splitting here on the fold result for readability */, "type": "nominal", "title": null}, "yOffset": { "field": "class", "type": "nominal", "sort": {"field": "y", "order": "ascending"} } }, "layer": [ { "mark": {"type": "bar", "tooltip": true}, "encoding": { "color": { "field": "class", "type": "nominal", "scale": {"range": {"field": "class_color"}}, "title": null } } }, { "mark": { "type": "text", "align": "right", "xOffset": -4, "color": "white" }, "encoding": {"text": {"field": "class", "type": "nominal"}} } ] }Checklist
Feel free to rename the issue with a better name than mine, as I'm not convinced the current one is very helpful.