Reputation: 522
In this example vega lite link, if you select an item from the legend, and then click anywhere in the chart area, the legend selection resets.
If I use interval selection to enable panning and zooming, and I have legend items selected, the legend gets reset anytime I click to pan.
Is there anyway to prevent that?
Upvotes: 1
Views: 382
Reputation: 2416
The bind
config can be taken as an object having the legend
which takes configs of Event Streams. Then, you can simply provide a unique markname
that will trigger the click event when legend of that name is clicked and Events originating from other marks will be ignored.
Below is the given configuration or refer editor:
{
"config": {"view": {"continuousWidth": 400, "continuousHeight": 300}},
"data": {
"url": "https://cdn.jsdelivr.net/npm/[email protected]/data/cars.json"
},
"mark": {"type": "circle", "size": 60},
"encoding": {
"color": {"type": "nominal", "field": "Origin", "legend": {}},
"x": {"type": "quantitative", "field": "Horsepower"},
"y": {"type": "quantitative", "field": "Miles_per_Gallon"}
},
"selection": {
"intervalSelect": {"type": "interval"},
"selector003": {
"type": "multi",
"bind": {"legend": {"type": "click", "markname": "legendMark"}},
"fields": ["Origin"]
}
},
"$schema": "https://vega.github.io/schema/vega-lite/v4.8.1.json"
}
Upvotes: 1