I would like to achieve something like using boundsx
tool to select multiple ranges on a plot and use multiple VSpan
s to visualize the underlying selections. My requirement is to first coarsely select the range by boundsx
tool, and then fine tune the bounds in an editable ItemTable
. I was able to use a external list to keep the selections but I have no idea how can I use the ItemTable to edit the underlying list (span_list
).
I have seen a couple of examples such as curveedit. This example worked because the data of the curve can be linked to the table. In my case the data should be extracted from a DynamicMap and its wrapped elements. I wonder whether this is possible? Is there a better way to achieve this?
Thank you!
Here are the minimal example that could display the boundaries of VSpan
s but not able to edit them in the ItemTable
:
import holoviews as hv
from holoviews import opts
import numpy as np
hv.extension('bokeh')
x = np.arange(10)
y = np.random.rand(10)
# dummy curve
curve = hv.Curve((x, y))
span_lists = []
bx = hv.streams.BoundsX(source=curve, boundsx=(0, 0))
def dmap_func(boundsx):
if boundsx[0]:
span_lists.append(boundsx)
return hv.Overlay([hv.VSpan(x1=x[0], x2=x[1]) for x in span_lists])
dmap = hv.DynamicMap(dmap_func, streams=[bx])
def dtable_func(boundsx):
left = [x[0] for x in span_lists]
right = [x[1] for x in span_lists]
return hv.ItemTable([('Left', left), ('Right', right)])
dmap_tb = hv.DynamicMap(dtable_func, streams=[bx])
(curve * dmap + dmap_tb).opts(
opts.Curve(responsive=True, height=400),
opts.VSpan(color='b')
).cols(1)