Hi, I have a small app composed of a dataframe and a layout of 2 plots. The bottom plot is linked with a BoundsX stream, which extracts the range selected, add it to the dataframe and display a Vspan on the first plot.
In the end, the user would make several quick selection, but I have 2 problems.
- If the user is too fast, the grey box for the selection doesn’t appear, It could be irritating for some user.
- and if the process called by the stream takes too long, the script skip some selections.
My questions are :
Is there a way to dissociate the selection and the other process activated by param.depends, in order for the browser to keep the select box displayed ? (Maybe gather all selections and update once or parallelize each callback called by each selection)
Is there a minimum amount of time between two callback and is there a parameter to change it ? Or there is a way to manage more precisely the event buffer ?
I have posted those problems in panel, because It happens mostly when some panel view are refreshed by the stream.
the code :
import param
import pandas as pd
import hvplot.pandas
import holoviews as hv
from holoviews import streams
import panel as pn
class App_debug(param.Parameterized):
list_sp=[]
df_st=param.DataFrame(pd.DataFrame(columns=['beg','end']))
def __init__(self,**params):
super().__init__(**params)
index=pd.date_range(start="2018-01-01",end="2018-12-31")
self.plot=pd.DataFrame(data=range(len(index)),index=index,columns=['val']).val.hvplot(datashade=True).options(toolbar=None,default_tools=['wheel_zoom','reset'],active_tools=['box_select','wheel_zoom'],yaxis=None)
rangex=streams.BoundsX(source=self.plot,boundsx=('2018-12-01','2018-12-02'))
rangex.add_subscriber(self.recup_range)
self.p_=pd.DataFrame(data=range(len(index)),index=index,columns=['val']).val.hvplot(datashade=True).options(toolbar=None,yaxis=None)
self.p_.opts(alpha=0)
@param.depends('df_st')
def view_df(self):
return hv.Table(self.df_st)
@param.depends('df_st')
def span(self,*events):
sp=hv.Overlay(self.list_sp)
return (self.p_*sp).opts(show_legend=False,yaxis=None,toolbar=None)
def recup_range(self,boundsx):
b,e=boundsx
df_=self.df_st
df_.loc[-1]=[str(b),str(e)]
df_.index=df_.index+1
df_.sort_index(inplace=True)
self.list_sp.append(hv.VSpan(pd.Timestamp(b),pd.Timestamp(e)).opts(color='#f89e9e',alpha=0.4))
self.df_st=df_
@param.depends()
def view(self):
return self.plot
viewer=App_debug()
pn.Row(pn.Column(viewer.span,viewer.view),viewer.view_df).show()