'Color specific region based on user selection
In the documetation, there is an attibute selected while calling go.choropleth to build a map. I want to ask if anyone knows what is it for?
Because currently I have a map of regions of France. I want that when a user clicks on a specific region, this region should be shaded with light blue color.
Solution 1:[1]
I was looking for clickmode='event+select' like that:
fig = px.choropleth(df1, geojson=jdataNo, color="winner",
locations="district", featureidkey="properties.NAME_1",
projection="gnomonic", color_discrete_sequence=['red','green','blue']
)
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0},clickmode='event+select')
fig.show()
In Dash, I can use clickData to read which region is clicked, as suggested by @r-beginners.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Phoenix |

