Accessing customdata with the hovertemplate via scattermapbox plot-

Having some issues grabbing the customdate with a hovertemplate in a scattermapbox trace. Here is a snippet of code I have:

fig = go.Figure(data=go.Scattermapbox(
    lon=[data.start_lon],
    lat=[data.start_lat],
    customdata = [data.start_head,data.sog],
    mode='markers',
    marker = dict(
        color=display['primary_point']['color'],
        size=display['primary_point']['size'],
    ),
    name='Initial Point',
    text = 'Initial Point',
    hovertemplate=
    "<extra></extra><b>%{fullData.name}</b><br>" +
    "Longitude: %{lon}<br>" +
    "Latitude: %{lat}<br>" +
    "Heading: %{customdata[0]}<br>"

    ))

When I hover over that, the “Heading” portion literally says ‘%{customdata[0]}’. If I take off the index (i.e. [0]), and just say customdata, it points it at the first item in the list. Any thoughts? (data is just a class I store variables in)

Try changing data to a pandas Dataframe, then each point will pull the data from the appropriate row in the columns. ie

lon=df[‘lon’]
lat=df[‘lat’]
customdata=df[‘mycustomdata’]
etc

Or, just remove the array you are creating in customdata if you aren’t even using the second element of it. Clearly the template resolution is not a literal passing of text-as-code, it likely undergoes some sanity checks etc to prevent raw code injection.