Add blank dropdown option that doesn't filter
See original GitHub issueI have a chart with a dropdown selector, and the selection is responsible for filtering the data displayed in the chart. I’m trying to add a “blank” option to the binding_select that will result in no filtering (i.e. “display all data”). Is there an easy way to do that?
I was looking at alt.condition and filter predicates, but wasn’t able to figure it out. I was playing with the following example, where i’d want an “All” selection in the binding_select:
import altair as alt
from vega_datasets import data
cars = data.cars.url
input_dropdown = alt.binding_select(options=['All', 'Europe','Japan','USA'])
selection = alt.selection_single(fields=['Origin'],
bind=input_dropdown,
name='Country of ',
init={'Origin': 'Europe'})
color = alt.condition(selection,
alt.Color('Origin:N', legend=None),
alt.value('lightgray'))
alt.Chart(cars).mark_point().encode(
x='Horsepower:Q',
y='Miles_per_Gallon:Q',
color='Origin:N',
tooltip='Name:N'
).add_selection(
selection
).transform_filter(
selection
# Looking for something like <no filter> if selection == 'All' else selection
)
Thanks for the library and for the help!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Adding A Blank Option in a Data Validation Drop Down List in ...
Today we will walk through a couple of ways you can achieve adding a blank/empty value to the beginning of your Data Validation...
Read more >How to Add a Blank Item in a Drop-Down List in Excel - YouTube
In this video, I demonstrate how to add a ' blank ' option to a data validation drop-down list in Excel. The '...
Read more >How to Add Blank Option to Drop Down List in Excel (2 Methods)
1. Use Empty Cell as Reference to Add Blank Option in Excel Drop Down List. In this method, I will add a blank...
Read more >Adding All or Blank option to dropdown list
Solved: Hi I've created a Dropdown box to filter gallery contents. The dropdown gets its contents from a SharePoint list.
Read more >How To Add A Blank Value To A Dropdown List In Power Apps
But after enabling AllowEmptySelection the confusing part is once a user clicks to view the dropdown list there is no blank option at...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh, sorry, you have to use selection names that are valid identifiers. Try this:
@ZaxR I am going through Altair issues to find those that have been resolved and can be closed. It looks to me like this issue has been solved so I am closing it, but please feel free to reopen and add a comment if there is something you don’t think is resolved yet.