World Map + Slider In Altair (Python)
I would like to build an interactive chart with world map with COVID-19 confirmed cases per country and date slider using Altair library in python. Data format: 'country_region','d
Solution 1:
The problem appears to be that in Vega, lookup transforms do not dynamically recompute in response to selections. You can address this by switching which is the primary data source, so that all timestamps appear in the final joined dataset:
alt.Chart(df).mark_geoshape()\
.encode(color='rate:Q')\
.add_selection(select_date)\
.transform_filter(select_date)\
.transform_lookup(
lookup='id',
from_=alt.LookupData(countries, key='id',
fields=["type", "properties", "geometry"])
)\
.project('equirectangular')\
.properties(
width=500,
height=300,
title='Title'
)
Post a Comment for "World Map + Slider In Altair (Python)"