But without success since the vertical axis is also linked. Is there also a way to limit wheel zoom to one axis only ?
You can limit the scale binding to a single axis by specifying the "encodings"
property of the selection. For example, this binds the selection only to the x-axis (view in vega editor):
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {"url": "data/stocks.csv"},
"vconcat": [
{
"transform": [{"filter": "datum.symbol==='IBM'"}],
"mark": "line",
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"}
},
"selection": {
"region": {"type": "interval", "bind": "scales", "encodings": ["x"]}
}
},
{
"transform": [{"filter": "datum.symbol==='GOOG'"}],
"mark": "line",
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"}
},
"selection": {
"region": {"type": "interval", "bind": "scales", "encodings": ["x"]}
}
}
],
"resolve": {"scale": {"x": "shared", "y": "independent"}}
}
If you want independent y scale binding in each chart, with a shared x-binding, you can do this by adding a new independent bound selection in each chart (vega editor):
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {"url": "data/stocks.csv"},
"vconcat": [
{
"transform": [{"filter": "datum.symbol==='IBM'"}],
"mark": "line",
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"}
},
"selection": {
"y_scroll_1": {"type": "interval", "bind": "scales", "encodings": ["y"]},
"x_scroll": {"type": "interval", "bind": "scales", "encodings": ["x"]}
}
},
{
"transform": [{"filter": "datum.symbol==='GOOG'"}],
"mark": "line",
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"}
},
"selection": {
"y_scroll_2": {"type": "interval", "bind": "scales", "encodings": ["y"]},
"x_scroll": {"type": "interval", "bind": "scales", "encodings": ["x"]}
}
}
],
"resolve": {"scale": {"x": "shared", "y": "independent"}}
}