I am using depends
to link a variable selector to a plot:
@pn.depends(variable=variable)
def copernicus_plot(variable):
print(variable)
/* create plot */
return plot
I am displaying this plot in a Card which I am then adding to a bootstrap template:
copernicus_card = pn.Card(copernicus_plot)
But when I set my template to servable
and launch it with panel serve
, picking a value in the variable selector does not update the plot. It works fine if I show the template with show
.
The final dashboard is created as follow:
copernicus_tab = pn.Column(
description,
copernicus_card,
)
dashboard = pn.Tabs(
("Copernicus Data", copernicus_tab),
css_classes=["tabs"],
max_width=1024,
)
page.main.append(dashboard)
page.sidebar.append(pn.Card(
variable,
title="Select an impact to show",
))
page.servable()
variable
is a simple Selector as follows:
variable = pn.widgets.Select(options=[
/* options */
])
I have also tried using callbacks as follows:
def copernicus_callback(target, event):
logger.info("Callback: " + event.new)
print("Callback: "+event.new)
print(target)
copernicus_card = pn.Card(copernicus_plot)
variable.link(copernicus_card, {'value': copernicus_callback})
variable.value = "AD03"
But this doesn’t work either. The callback is called the first time the app is loaded but not on subsequent changes.
What am I doing wrong?