Is it possible to link multiple vega charts on a web page without making them into one combined chart?
I'm trying to do this in a dashboard to allow me more control of styling, particularly by putting the graphs on different tiles and making those responsive. As per the documentation, combined charts cannot be made responsive with "width": "container".
I created the following two example charts and embedded them into one HTML file, but I'm getting the following exception: Uncaught (in promise) Error: Cannot find a selection named "selector002".
Is there any way to make this work with Vega? Alternatively, I'd be happy with a vconcat chart if I can somehow get it to adjust to the size of its parent container.
{
"config": {
"view": {
"continuousWidth": 400,
"continuousHeight": 300
}
},
"data": {
"name": "data-07d1121d4bb402da807ced7f89269752"
},
"mark": "point",
"encoding": {
"x": {
"type": "quantitative",
"field": "A"
},
"y": {
"type": "quantitative",
"field": "B"
}
},
"selection": {
"selector002": {
"type": "interval",
"encodings": [
"x"
]
}
},
"width": "container",
"$schema": "https://vega.github.io/schema/vega-lite/v4.8.1.json",
"datasets": {
"data-07d1121d4bb402da807ced7f89269752": [
{
"A": 0.1,
"B": 0.5,
"C": 1.0
},
{
"A": 0.1,
"B": 0.8,
"C": 0.0
},
{
"A": 0.0,
"B": 1.0,
"C": 1.0
},
{
"A": 0.2,
"B": 0.8,
"C": 1.0
},
{
"A": 0.2,
"B": 0.9,
"C": 0.0
}
]
}
}
{
"config": {
"view": {
"continuousWidth": 400,
"continuousHeight": 300
}
},
"data": {
"name": "data-07d1121d4bb402da807ced7f89269752"
},
"mark": "bar",
"encoding": {
"color": {
"type": "ordinal",
"field": "B"
},
"x": {
"type": "quantitative",
"field": "A"
},
"y": {
"type": "ordinal",
"field": "C"
}
},
"transform": [
{
"filter": {
"selection": "selector002"
}
}
],
"width": "container",
"$schema": "https://vega.github.io/schema/vega-lite/v4.8.1.json",
"datasets": {
"data-07d1121d4bb402da807ced7f89269752": [
{
"A": 0.1,
"B": 0.5,
"C": 1.0
},
{
"A": 0.1,
"B": 0.8,
"C": 0.0
},
{
"A": 0.0,
"B": 1.0,
"C": 1.0
},
{
"A": 0.2,
"B": 0.8,
"C": 1.0
},
{
"A": 0.2,
"B": 0.9,
"C": 0.0
}
]
}
}