OpenUrl with for loop lines

Hello,
I am looking for a way to make each line in the for loop clickable with opening a http url.

I don’t know how to do it… been looking for a solution. can someone help me?

last thing I tried is the following:
taptool = plot.select(type=TapTool)
taptool.callback = OpenURL(url=’/samples/’ + str(row.sample_pk))

but it assign the same link to to all the lines.

palette = all_palettes['Viridis'][11]
spectra = regressor.samples_spectra_annotated_dataframe
min_y = min([spectra.y_dev.min(), spectra.y_prod.min(), spectra.y_ref.min()])
max_y = max([spectra.y_dev.max(), spectra.y_prod.max(), spectra.y_ref.max()])
xvalues = regressor.samples.first().measures.first().device.wavelengths
x_start, x_stop = xvalues[0], xvalues[-1]

plot = figure(plot_width=1100, plot_height=500, x_range=(x_start, x_stop), toolbar_location="below",
                       sizing_mode='scale_width', tools='tap,hover')
plot.xaxis.axis_label = "Wavelengths [nm]"
plot.yaxis.axis_label = "Absorbance"

mapper = LinearColormap(palette, vmin=min_y, vmax=max_y)
color_bar_mapper = linear_cmap(field_name='y_ref', palette=palette, low=min_y, high=max_y)

labels = []
lines = []

color_count = 0
for index, row in spectra.iterrows():
    label = index
    line_dash_value = 'dashed' if row.through_packaging else 'solid'
    line = plot.line(
        x=xvalues,
        y=row['input_0':'input_124'],
        alpha=1,
        line_width=2,
        line_dash=line_dash_value,
        muted_alpha=0,
        color=mapper.rgb_hex_str(row.y_ref)
    )
    labels.append((label, [line]))
    lines.append([line])
    plot.add_tools(HoverTool(renderers=[line], toggleable=False, tooltips=[("Sample", label)]))
    taptool = plot.select(type=TapTool)
    taptool.callback = OpenURL(url='/samples/' + str(row.sample_pk))
    color_count += 1

legend = Legend(items=labels, location=(10, 0))
legend.click_policy = "mute"
plot.toolbar.autohide = True
color_bar = ColorBar(color_mapper=color_bar_mapper['transform'], width=8)

plot.add_layout(color_bar, 'right')

script, div = components(plot)

@fcoppey I would be happy to try and run the code to investigate it, but you would need to first simplify and strip it down, removing anything unrelated to the issue, as well as add the missing pieces (imports, etc), i.e. provide a complete Minimal Reproducible Example.