Hello
I am triying to do a callback but the map is not working.
The process is the follow:
- If you select in the check box “Poblacion” you should to see the choropleth map (This is not working)
- If you select in the check box “Ingreso” you should to see a bar (This is ok)
However when you select “Poblacion” nothing appear in the graph. I was trying many things for a couple weeks but without succesful.
Thanks
html.Div(
className='row app-body',
children=[
dcc.Checklist(
id = 'MapFilter',
options=[
{'label': 'Poblacion', 'value': 'Poblacion'},
{'label': 'IngresosPromedio', 'value': 'IngresosPromedio'}
],
value=['Poblacion'],
labelStyle={'display': 'inline-block'}
),
]),
html.Div([
html.Div([
dcc.Graph(
id='MapPlot',
style={
"height":"900px",
"width":"110%"
},
),
],className="six columns"),
@app.callback(
dash.dependencies.Output('MapPlot', 'figure'),
[dash.dependencies.Input('MapFilter', 'value')])
def update_image_src2(selector):
data = []
if 'Poblacion' in selector:
data.append({'type': 'Choroplethmapbox','geojson': 'counties','locations': dfPobMap.Name_Dpto, 'z': dfPobMap.fex_c_2011_x,'colorscal':'Viridis','colorbar_title': 'Población'})
if 'IngresosPromedio' in selector:
data.append({'x': dfIncomeAverage2["Name_Dpto"], 'y': dfIncomeAverage2["INGLABO"], 'type': 'bar', 'name': '2019'})
figure={
'data': data,
'layout': go.Layout(
mapbox_style="carto-positron",
mapbox_accesstoken=token,
mapbox_zoom=4.3,
mapbox_center = {"lat": 4.208112, "lon": -72.739072},
)
}
return figure