This map has two RadioItems options at bottom left of page. It starts with the regular
value, as in image:
The callback works well if user moves between
charter
and regular
as many times as she wants. However, if the RadioItem is on regular
and the user clicks on a legend item or clicks on a marker in order to isolate it in the map, the RadioItem stops working (the user cannot move to charter
; nothing happens). Oddly enough, if RadioItem is on charter
and the user isolates a marker, there is no problem; the RadioItem still works and the user can switch back to `regular.
In other words, user cannot choose charter
if (RadioItem is on regular
) AND (a marker is isolated).
Is this a bug in the RadioItem… because I’m loosing my mind?
app = dash.Dash()
app.layout = html.Div([
dcc.Graph(id='graph'),
dcc.RadioItems(id='type_picker',
options=[
{'label': 'regular', 'value': 'regular'},
{'label': 'charter', 'value': 'charter'}
],
value='charter'
),
@app.callback(Output('graph', 'figure'),
[Input('type_picker', 'value')])
def update_figure(selected_school):
# Create Figure
filtered_school_type = df4[df4['school_type'] == selected_school]
interest_areas = list(filtered_school_type.interest1.unique())
schools=[]
for i in interest_areas:
df_sub=filtered_school_type[filtered_school_type.interest1==i]
schools.append(go.Scattermapbox(
lon = df_sub['Longitude'],
lat = df_sub['Latitude'],
mode='markers',
customdata=df_sub['link'],
...,
))
return {
'data': schools,
'layout': go.Layout(
clickmode= 'event+select',
showlegend = True,
mapbox=dict(
accesstoken=mapbox_access_token,
...,
),
)
}
if __name__ == '__main__':
app.run_server()