I am following this tutorial [github] on using Panel and Altair.
The function which returns my plot is the following:
@pn.depends(ticker.param.value, date_range_slider.param.value)
def get_plot(ticker, date_range):
df = data.stocks()
df['date'] = pd.to_datetime(df['date'])
start_date, end_date = date_range
mask = (df['date'] > start_date) & (df['date'] <= end_date)
dfm = df.loc[mask]
chart = (alt.Chart(dfm)
.mark_line()
.encode(
x='date', y='price',
tooltip=alt.Tooltip(['date', 'price']))
.transform_filter((datum.symbol == ticker))
)
return chart
I am running into an issue where the chart is shown normally if executed directly:
but not when run using Panel:
It seems that when i put my working chart
into a panel
it loses the link to the data:
Serving the dashboard has the same problem so it seems to me there is a compatibility issue between Panel and Altair.
Anyone know what is wrong and how to fix it?
Versions:
- Panel - v0.6.0
- Altair - v3.2.0
- Pandas - v0.25.1
- JupyterLab - v1.0.2
- Python - v3.7.4