✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Point_inds is empty when I select the scatter, why?

Hi,
This is my code but I don’t understand why point_inds is empty.
Without slider it works.
I can’t find the error

data_slider=[]

for year in dataset.Year.unique():
    data = dataset.query("Year==@year")

    data_one_year = go.Scattergeo(
        locationmode = 'ISO-3',
        locations=data['iso_alpha'],
        text = data['Country'],
        mode = 'markers',
        marker = dict(
            size = (data['Value_Air'])/70000,
            colorscale = 'Viridis',
            color = data['Value_Co2'],
            line_color='rgb(0,0,0)',
            opacity=1,
            cmin=minValueC,
            cmax=maxValueC,
            line_width=0.9,
            colorbar=dict(
            title="Colorbar",
        ),
        ))

    data_slider.append(data_one_year)  


steps = []

for i in range(len(data_slider)):
    step = dict(method='restyle',
                args=['visible', [False] * len(data_slider)],
                label='Year {}'.format(i + minYear)) # label to be displayed for each step (year)
    step['args'][1][i] = True
    steps.append(step)


sliders = [dict(active=0, pad={"t": 1}, steps=steps)]  
layout = dict(sliders=sliders)

figure = dict(data=data_slider, layout=layout)
f2 = go.FigureWidget(figure)

def update_point(trace, points, selector):
    print(points)
    for i in points.point_inds:
        iso=(trace.locations[i])
        country=(trace.text[i])
    prova=dataset.query("iso_alpha==@iso")
    fig = go.Figure(data=[go.Bar(
    x=prova["Year"],
    y=prova["Value_Co2"],
    name='Value_Co2',
    marker_color='red',
    )])
    
    fig.add_trace(
    go.Bar(x=prova["Year"],y=prova["Value_Air"],marker_color='lightsalmon', name='Value_Air'),
    )
    
    fig.update_layout(barmode='group', title=str(country),xaxis_tickangle=-45,margin=dict(
        l=1,
        r=1,
        b=1,
        pad=3
    ),
    )
    fig.show()
 

f2.data[0].on_click(update_point)
f2

Any idea what is the issue?

Catturafa