Dropdown Menu in Geoshape Chart
See original GitHub issueHello,
I’m currently having troubles to integrate a dropdown menu into a geoshape chart with the following code:
source = alt.topo_feature(data.world_110m.url, "countries")
background = alt.Chart(source).mark_geoshape(fill="black")
input_dropdown = alt.binding_select(options=['GISAID','CNCB'])
selection = alt.selection_single(fields=['Community'], bind=input_dropdown, name='Community')
color = alt.condition(selection,
alt.Color('Count:N', legend=None),
alt.value('lightgray'))
foreground = (
alt.Chart(source)
.mark_geoshape(stroke="black", strokeWidth=0.15)
.encode(
color=color,
tooltip=[
alt.Tooltip("country:N", title="Country"),
alt.Tooltip("countryID:N", title="ID"),
alt.Tooltip("Count:Q", title="No. of Submissions"),
],
).transform_lookup(
lookup='id',
from_=alt.LookupData(completeDFLong, key='countryID',
fields=['country','countryID','Community','Count'])
)
.properties(
title='Locations of Submissions in selected Community'
).add_selection(
selection
).transform_filter(
selection
)
)
final_map = (
(background + foreground)
.configure_view(strokeWidth=0)
.configure_title(
fontSize=20,
color='black'
)
.properties(width=700, height=600)
.project("naturalEarth1")
)
final_map
The structure of the complete Dataframe is as follows:
But unfortunately changing the selection in the dropdown menu doesn’t change the chart. Also coloring doesn’t match the “Count” column:
Is it even possible to use a dropdown menu for a geoshape chart? All examples I found in the documentation were used in mark_point()
instead of mark_geoshape()
If yes, how can I make sure that the selected item is passed into the selection
variable and subsequently into the color encoding?
Thank you in advance and best regards!
Issue Analytics
- State:
- Created 3 years ago
- Comments:12
Top Results From Across the Web
python - altair: mark_geoshape tooltips disabled when adding ...
I have a GeoDataFrame, that I plot as a mark_geoshape-map (map_). The color and tooltip is based on a specific column ('Pkw-Dichte').
Read more >Geoshape field type | Elasticsearch Guide [8.5] | Elastic
The geo_shape mapping maps GeoJSON or WKT geometry objects to the geo_shape type. To enable it, users must explicitly map fields to the...
Read more >Good Morning! Is it possible to to zoom to a locat...
Is it possible to pre-load points into 123, link them to a drop down menu that once selected will change the map view...
Read more >Geographic shape vector - MATLAB - MathWorks
A geoshape vector is an object that represents geographic vector features with either point, line, or polygon topology.
Read more >Field type: geoshape - SurveyCTO Documentation
geoshape : collects GPS coordinates that form a polygon enclosing an area, ... Long-press again at another location on the map to drop...
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 FreeTop 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
Top GitHub Comments
Think reverse. Lookup the
geometry
instead of thestats
.In combination with
alt.Chart(ds)
.Full spec:
YES, it worked! Thank you very much @joelostblom and @mattijn