I am attempting to create an interactive Choroplethmapbox using plotly dash mapbox. My goal is to allow the user to select points on the map. The points that are selected are then returned in the callback and the map is updated such that the selected points retain their colorscale, but the nonselected points are reverted to a different colorscale.
I am at the point where I can access the correct selected points, but now the issue is that when I attempt to rebuild the map I cannot pass more than a single colorscale to the frames. In the code below I attempted to add a dataframe column that specified the colorscale depending on if it was a selected or non-selected point. But I get the error ā Invalid value of type numpy.ndarray' received for the 'colorscale' property of choroplethmapbox
and this error is produced regardless if the input is a list or a Dataframe series. Plotly will only accept a single colorscale argument it appears.
frames = [{
'name':'frame_{}'.format(today+'_'+time),
'data':[{
'type':'choroplethmapbox',
'z':df['z_score_'+today+'_'+time],
'locations' : df['ids'],
'colorscale' : df['colorscale'].values,
'colorbar' : dict(thickness=20, ticklen=3),
'geojson' : new_jfile,
'text' : df['polygons'],
'hovertemplate' : '<br> <b>Hot Spot </b>: %{z}<br>',
'marker_line_width':0.1,
'marker_opacity': 0.7
}],
} for today,time in dates_times]
Iām thinking my only other option is to somehow create a second layer that separates the non selected points from the selected points, but so far I cannot find any resources on if that is even possible. In addition, it is crucial that the interaction still exists in the other layer. Any help would be much appreciated.