vega-lite: Error: Undefined data set name: "scale_concat_1_child_main"
I am trying to hconcat a faceted graph over two fields with a summary graph (summing across one of the fields). If I have color set in the first chart, then I get the error listed in the title (Undefined data set name: "scale_concat_1_child_main").
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.json",
"data": {
"values": [
{
"c1": "Argagarg",
"c2": "Argagarg",
"mu": "2-8",
"win_chance": 0.2,
"p": 0.005293199778439004,
"type": "global",
"cum_p": 0.49384000294641295
},
{
"c1": "Argagarg",
"c2": "BBB",
"mu": "2.5-7.5",
"win_chance": 0.25,
"p": 0.006317783956548739,
"type": "global",
"cum_p": 0.4182141361083573
},
{
"c1": "BBB",
"c2": "Argagarg",
"mu": "4-6",
"win_chance": 0.39999999999999997,
"p": 0.00599613286508726,
"type": "global",
"cum_p": 0.5810908430205882
},
{
"c1": "BBB",
"c2": "BBB",
"mu": "2.5-7.5",
"win_chance": 0.25,
"p": 0.017437015257325033,
"type": "global",
"cum_p": 0.5011573865688447
}
]
},
"transform": [
{
"joinaggregate": [
{
"op": "mean",
"field": "cum_p",
"as": "c1_avg_cum_p"
}
],
"groupby": [
"c1"
]
}
],
"hconcat": [
{
"facet": {
"row": {
"field": "c1",
"type": "ordinal"
},
"column": {
"field": "c2",
"type": "ordinal"
}
},
"spec": {
"mark": {
"type": "bar"
},
"encoding": {
"x": {
"field": "mu",
"type": "ordinal"
},
"y": {
"field": "p",
"type": "quantitative"
},
"color": { // If I remove this object, the graph works
"field": "cum_p",
"type": "quantitative"
}
}
}
},
{
"facet": {
"row": {
"field": "c1",
"type": "ordinal"
}
},
"spec": {
"mark": {
"type": "bar"
},
"encoding": {
"x": {
"field": "mu",
"type": "ordinal"
},
"y": {
"aggregate": "mean",
"field": "p",
"type": "quantitative"
},
"color": {
"aggregate": "mean",
"field": "c1_avg_cum_p",
"type": "quantitative"
}
}
}
}
]
}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 16 (7 by maintainers)
I’m experiencing the same error. Here is my minimal example (no
transformorcolorlike in the issue).Is anybody working on this issue? And is there a workaround? (The workaround not using
facetbut ratherconcatandfilteris not feasible for me, since I have a large number of faceted values).I ran into this today and have been troubleshooting for a bit. I noticed that it only happens for concatenating charts using the same data source. When passing charts with different data sources, there are no issues. This is also why the filter workaround works, it creates two separate data sources in the compiled Vega spec.
The reason it does not work with the same data source is that VegaLite for some reason passes a non-existing dataset name to Vega instead of reusing the name of the dataset used in the first concatenated chart. Here is an example of the compiled Vega from @trubens71 's example above:
The second entry is referencing a dataset name that doesn’t exist and changing this to
data_2as in the first concatenated chart will fix the issue.I would PR, but I am not sure where in VL this incorrect name is created and couldn’t figure it out from looking briefly at the source, so happy for anyone else to do it, I just want to be able to concatenate faceted charts =)
Additional workarounds to those mentioned is to reorder the dataset before passing it to VegaLite (e.g. in Altair) so that it is not recognized as the same dataset, or using a boxplot (which I think doesn’t have this issue because it creates separate aggregated datasets).
I believe a PR for this would also close #5475 and solve half of https://github.com/vega/vega-lite/issues/5261.
As a short term fix, I note that if you add a:
to each part of the
vconcat(e.g. filters that have no effect), then it works.Note in some examples the transforms seem to have to be _different _ in each part of the vconcat
here is an example
I could see two reasons for this issue. 1) we are not renaming the data field in assemble to be the correct reference or 2) we are accidentally deleting a required data source because the reference counter is not increased. It’s probably 1.