A plotly chloropleth_mapbox can be “scanned” and then depending upon the hoverdata, I want it to update another figure. I have tried it to separate it out with a child signal like this page (Part 5. Sharing Data Between Callbacks | Dash for Python Documentation | Plotly) but was not succesfull.
The second fig currently just shows all of the points, not the specific point.
A sample output for hoverData is
{
points:
{0:
{ * curveNumber0
- pointNumber131
- pointIndex131
- location"48085"
- z1553.3333333333333
*CustomData : { - 0"Collin"
- 11553.3333333333333
- 213.666666666666666
}
}
}
}
@app.callback(Output(‘fig_hrs’, ‘figure’), Input(‘fig_map’, ‘hoverData’))
def compute_value(hoverData):
city = hoverData[‘points’][0][‘customdata’][0]
df = df[df[“NAME”].isin(city)]
fig = px.histogram(df, x=‘AGE_NAME’,color=‘gender’,nbins=20,template=‘ggplot2’)
fig.update_layout(
paper_bgcolor="#f5f5f5", plot_bgcolor="#f5f5f5",
xaxis_showgrid=False, yaxis_showgrid=False,
yaxis_automargin=True, xaxis_automargin=True,
autosize = True,
legend=dict(orientation=“h”,
x=-0.027314112291350532,
y=1.1616071428571427,
xanchor=‘left’,
yanchor=‘top’))
fig.update_xaxes(title=“Age”)
fig.update_yaxes(title=“Count”)
return fig