I am trying to plot the states of India in altair.I am able to plot and in the tooltip state names are appearing.I want the state to pop out or change in color on selection.Is there any way to do it.
I tried to use selection_interval.But not able to do it as i am newbie
'''python
import altair as alt
url = "https://raw.githubusercontent.com/deldersveld/topojson/master/countries/india/india-states.json"
source = alt.topo_feature(url, "IND_adm1")
alt.Chart(source).mark_geoshape().encode(
tooltip='properties.NAME_1:N',
color=alt.value('lightgray')
).properties(
width=800,
height=500
)
You can use a Single Selection with a conditional color to do something like this:
import altair as alt
url = "https://raw.githubusercontent.com/deldersveld/topojson/master/countries/india/india-states.json"
source = alt.topo_feature(url, "IND_adm1")
hover = alt.selection_single(on='mouseover', empty='none')
alt.Chart(source).mark_geoshape().encode(
tooltip='properties.NAME_1:N',
color=alt.condition(hover, alt.value('steelblue'), alt.value('lightgray'))
).properties(
width=800,
height=500
).add_selection(
hover
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.