Hello,
I have a time series graph that the time axis corresponds to a video. I would like to select a time range on the graph using the box zoom tool and have the video update to start at the point I had selected. Below is example code on what I am doing
def combined_values(df):
time = df['time'].values
y = df['y_value'].values
time_plot = datashade(hv.Curve((time,y),kdims='time'))
video = pn.pane.Video('/file_path', loop = True)
return pn.Column(video, time_plot)
Any help would be appreciated.
Something like this should work. The basic idea is that datashade already attaches RangeXY and PlotSize streams which reflect the current axis ranges and sizes. Here we create these streams manually and then attach a callback to the RangeX
stream which will update the video timestamp when the axis range changes:
xstream, ystream = hv.streams.RangeX(), hv.streams.RangeY()
size_stream = hv.streams.PlotSize()
time_plot = datashade(hv.Curve((time, y),kdims='time'), streams=[xstream, ystream, size_stream])
video = pn.pane.Video('/file_path', loop = True)
def update_timestamp(event):
video.time = event.new[0]
xstream.param.watch(update_timestamp, 'x_range')
return pn.Column(video, time_plot)
That worked perfectly! Thank you for your help