Why is the MultiSelect rendered twice and the chart only once?

In the code below we get what we see in the screenshot:

Why is the MultiSelect rendered twice?

import pandas as pd
import hvplot.pandas
import panel as pn


csv_file = "https://raw.githubusercontent.com/metaperl/pure-python-web-development/main/examples/covid-ticker-data/data/ticker-data.csv"
ticker_df = pd.read_csv(csv_file, parse_dates=["Date"], index_col="Date")
all_tickers = ticker_df.Ticker.unique().tolist()

# Create a MultiSelect widget
selected_tickers = pn.widgets.MultiSelect(name='Tickers', value=all_tickers, options=all_tickers)

# Use the hvplot interactive API to create a pipeline that depends on this widget
one_tickeri = ticker_df.interactive()
one_tickeri = one_tickeri[one_tickeri['Ticker'].isin(selected_tickers)]
chart = one_tickeri.hvplot.line(x='Date', y='Close', by='Ticker')
# Displaying/Serving this pipeline includes its inputs (one widget in this case)
# and its output (one plot).
pn.Column('# COVID Tickers', selected_tickers, chart).servable()

hvplot.interactive outputs the widget used for its calculation. There is a way to get the output only, but I cannot remember it at the top of my head.

1 Like

The docs do not seem to have a reference that documents all the options that .interactive can be called with:

  1. the getting started section doesnt describe the API - interactive — hvPlot 0.9.0 documentation
  2. the user guide does not either - Interactive — hvPlot 0.9.0 documentation
  3. the search results dont seem to have anything either - Search - hvPlot 0.9.0 documentation
  4. the source for interactive doesnt really document what kwargs it accepts - https://github.com/holoviz/hvplot/blob/main/hvplot/interactive.py

actually the problem is not with the chart… it’s with the MultiSelect.

The reason you are seeing two is still because of the .interactive. Try: pn.Column('# COVID Tickers', selected_tickers, chart.output()).servable() or alternatively pn.Column('# COVID Tickers', chart).servable().

1 Like

the first one worked. I did not try the 2nd one. However, what part of the documentation covers this?

Can see chart.panel() is also valid.

The last example on this page: Interactive — hvPlot 0.9.0 documentation

1 Like

I added this explantion to the tutorial and fixed the typo in the docstring for interactive.

1 Like