简体   繁体   English

移动浏览器上 Vega-Lite 规范中的间隔选择

[英]Interval selections in Vega-Lite specifications on mobile browsers

The Altair example gallery contains a nice example of how to use interval selections to create two plots where one allows you to define the scale of the other. Altair 示例库包含一个很好的示例,说明如何使用区间选择创建两个图,其中一个图允许您定义另一个图的比例。

import altair as alt
from vega_datasets import data

source = data.sp500.url

brush = alt.selection(type='interval', encodings=['x'])

base = alt.Chart(source).mark_area().encode(
    x = 'date:T',
    y = 'price:Q'
).properties(
    width=600,
    height=200
)

upper = base.encode(
    alt.X('date:T', scale=alt.Scale(domain=brush))
)

lower = base.properties(
    height=60
).add_selection(brush)

upper & lower

在此处输入图片说明

If I embed the resulting specification on a page using vega-embed, I get something that works well on desktop browsers but seems to do little if anything on mobile browsers, where dragging along the graph does not create a selection.如果我使用 vega-embed 将生成的规范嵌入到页面上,我会得到一些在桌面浏览器上运行良好的东西,但在移动浏览器上似乎没有什么作用,沿着图形拖动不会创建选择。 I can remove a predefined selection by clicking on it in mobile browsers, but that doesn't achieve much.我可以通过在移动浏览器中单击来删除预定义的选择,但这并没有多大作用。 My question therefore becomes:因此,我的问题变成:

Is there any way to create Vega-Lite specifications, preferably in Altair, with interval selections that are intuitive to use on (any of the prevalent) mobile browsers, ideally by allowing users to create selections by dragging along the graph?有什么方法可以创建 Vega-Lite 规范,最好是在 Altair 中,在(任何流行的)移动浏览器上使用直观的间隔选择,理想情况下允许用户通过沿图形拖动来创建选择?

No, as of Vega-Lite v4.4 there is no way to make interactions/selections work on mobile.不,从 Vega-Lite v4.4 开始,无法在移动设备上进行交互/选择。 The bug that tracks adding this feature is here: https://github.com/vega/vega-lite/issues/4661跟踪添加此功能的错误在这里: https : //github.com/vega/vega-lite/issues/4661

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM