-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
I'm trying to use the click/hover callbacks in dash with a mapbox map that displays lines. I create each line with something like
go.Scattermapbox(
lat=lats,
lon=lons,
mode='lines',
hoverinfo='text',
name=row.segment_name,
customdata=row.segment_id,
text=row.segment_id,
showlegend=False
segment_id
or segment_text
appear nicely on hover, however in printing the callback I notice that the contents are
{
"points": [
{
"lat": 43.6464730064524,
"curveNumber": 2,
"lon": -79.4037543398975,
"pointNumber": 28
}
]
}
Is there a way to link curveNumber
back to the data that created the map? If I assign a numeric variable to customdata
, it doesn't appear in the callback. If I assign a string variable to customdata
, only 1 letter appears per point on the line.
Current workaround
My understanding is that whatever is consuming the customdata
is iterating over it for each generating point. I tried creating an iterator for the variable I want that iterates infinitely, but this gave me errors that repeat() is not JSON seriablizable. So my workaround is to create a list from repeating the segment_id
variable for the number of points there are in the line.
customdata=list(itertools.repeat(row.segment_id, times=len(lats))),