简体   繁体   English

如何取消选择 Altair 的下拉框

[英]How to deselect drop down box of Altair

My question is about the drop down box of Altair (Python's visualization library).我的问题是关于 Altair(Python 的可视化库)的下拉框。

In this example in the official document, you can select the country of origin of cars.在官方文档中的这个例子中,可以 select 的汽车原产国。 If you select one, then only the selected instances remain the same (or have the original color) and the other instances are grayed out.如果您是 select 之一,则只有选定的实例保持不变(或具有原始颜色)而其他实例灰显。

My question is: How can I cancel the selection?我的问题是:如何取消选择? Or is it possible to customize the code so that the drop box has the option for de-select?或者是否可以自定义代码,以便下拉框具有取消选择的选项?

You can change你可以改变

input_dropdown = alt.binding_select(options=['Europe','Japan','USA'])

to

input_dropdown = alt.binding_select(options=[None,'Europe','Japan','USA'],labels=['All','Europe','Japan','USA'])

This will add 'All' as an option in your drop-down.这将在您的下拉菜单中添加“全部”作为选项。 Clicking on it de-selects your previous selection.单击它会取消选择您之前的选择。

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

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