Choroplethmapbox is not displayed with geojson data

Hi,

I am trying to create a map of Lisbon, Portugal with Geojson and colour the districts with the corresponding value. However, the chart does not return anything but doesn’t show an error at the same time.

If you like to reproduce my problem you can find the data + code in this dropbox folder.

Maybe my mistake is also obvious so find below my used code:

app.layout = html.Div([
    dcc.Graph(id='graph')
])

@app.callback(
    Output('graph', 'figure')
)

def update_graph():
    global data

    fig = [go.Choroplethmapbox(
        geojson=districts, locations=data.district, z=data.price,
        featureidkey="properties.NOME", colorscale="Viridis", zmin=data.price.min(), zmax=data.price.max(),
        marker_opacity=0.5, marker_line_width=0)]

    layout = go.Layout(mapbox_style="carto-positron",
                      mapbox_zoom=3, mapbox_center={"lat": 38.7436057, "lon": -9.2302432},
                       )


    return {"data": fig, "layout": layout}

if __name__ == '__main__':
    app.run_server(debug=True)

Thanks for your help!

Hi @Maeaex1 you need an Input to trigger you callback, otherwise it will never be called (hence your graoh remains empty). Please take a look at https://dash.plot.ly/getting-started-part-2

I think this is the origin of the problem here, but in general if you think there can be a problem with a plotly figure, you can first build it in a cell of a Jupyter notebook, check that it’s ok, and then paste the code in your Dash app.

Thanks for the hint Emmanuelle! Works like a charm now :slight_smile: