hvplot and panel when combined are not clearing the plot between events
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 124
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 1
Description
I am trying to establish a dashboard using jupyter, panel and hvplot. This is the code snippet.
```
import pandas as pd
import panel.widgets as pnw
import panel as pn
import hvplot.pandas
pn.extension()
# some data cleansing yields a df containing the data of interest
df = pd.DataFrame.from_records([
{"product_name": "One", "name": "One-One", "revenue": 10, "customers": 50},
{"product_name": "One", "name": "One-Two", "revenue": 20, "customers": 150},
{"product_name": "Two", "name": "Two-One", "revenue": 30, "customers": 250},
{"product_name": "Two", "name": "Two-Two", "revenue": 40, "customers": 350},
])
products = df["product_name"].drop_duplicates()
def histogram_of_variant_revenue(selected_product=None):
selection = df[df["product_name"] == selected_product]
print(selection.shape)
return selection[["name", "revenue"]].drop_duplicates().set_index("name").hvplot.bar()
def histogram_of_variant_customers(selected_product=None):
selection = df[df["product_name"] == selected_product]
print(selection.shape)
return selection[["name", "customers"]].drop_duplicates().set_index("name").hvplot.bar()
selected_product = pnw.Select(name='Product', options=sorted(list(products)))
customers = pn.bind(histogram_of_variant_customers, selected_product)
revenue = pn.bind(histogram_of_variant_revenue, selected_product)
combined_panel = pn.Column(selected_product, customers, revenue)
combined_panel
```
At the default selection.

After the next use of the drop-down selection. Notice that instead of getting a new chart - the old one seems to have moved to the right and the new one placed into the figure.

Any idea on how I can get a new histogram after selecting from the drop-down?
Contributor guide
Assessment
This issue has not been assessed yet.