Issue with saving successive HoloViews plots in html

Hello,

I have encountered issues with saving HoloViews plots in html from successive instances of FileDownload widgets. The first time I try to get the file, it works. But if I update the layout with a new FileDownload, nothing happens when I click on the new widget.

The result is the same with hv.save or panel’s save function, with a file on disk or a file-like object. See the following code:


import functools
import numpy as np
import panel as pn
import holoviews as hv

pn.extension()


def callback(clicks):
    plot = hv.Scatter(([0, 1, 2, 3, 4], clicks*np.arange(4)))
    use_panel = True
    filename = f'file{clicks}.html'
    if use_panel:
        pn.panel(plot).save(filename, embed=True)
    else:
        hv.save(plot, filename)
    return filename


def add_filedownload(event):
    col.clear()
    clicks = event.new
    col.append(pn.widgets.FileDownload(label=f'Download plot #{clicks}',
                                       callback=functools.partial(callback, clicks=clicks)))


button = pn.widgets.Button(name='Add filedownload')
button.on_click(add_filedownload)
col = pn.Column()
pn.Column(button, col).servable()

It works fine for png files though. Is there something wrong with my code?

I use panel 0.14.1 and holoviews 1.15.1