使蔬食选择只在鼠标向上时生效

  • 本文关键字:鼠标 选择 vega-lite vega
  • 更新时间 :
  • 英文 :


我希望在Vega-lite中有一个间隔选择,其中其他数据在响应选择时被过滤,但仅在用户释放鼠标之后。例如,考虑这个示例,其中用户可以通过选择另一个图表上的范围来过滤时间序列图中的日期。当用户在底部图表中拖动选择时,顶部图表将实时过滤。我想做的是,只有当用户更新了底部图表中的选择并释放了鼠标按钮时,才使用顶部图表过滤器。

试试这个。我觉得有点尴尬,但还是照你说的做了。

编辑
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"url": "data/sp500.csv"},
"vconcat": [
{
"width": 480,
"mark": "area",
"encoding": {
"x": {
"field": "date",
"type": "temporal",
"scale": {"domain": {"param": "brush"}},
"axis": {"title": ""}
},
"y": {"field": "price", "type": "quantitative"}
}
},
{
"width": 480,
"height": 60,
"mark": "area",
"params": [
{
"name": "brush",
"select": {
"type": "interval",
"encodings": ["x"],
"on": {
"type": "mousemove",
"between": [{"type": "mouseup"}, {"type": "mousedown"}]
}
}
}
],
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {
"field": "price",
"type": "quantitative",
"axis": {"tickCount": 3, "grid": false}
}
}
}
]
}

最新更新