My goal is to have labels in a plot that are movable by the user. So I am looking for the label equivalent of the PointDraw stream.
Tried so far:
import holoviews as hv
from holoviews import streams
import panel as pn
from holoviews.plotting.links import DataLink
hv.extension('bokeh')
data = [[1, 2], [3, 1], [2, 3]]
labels = hv.Labels({('x', 'y'): data, 'text': ['a', 'b', 'c']}, ['x', 'y'], 'text')
Attempt 1: Trying to apply the PointDraw stream to a label object
stream = streams.PointDraw(data=labels.columns(), source=labels)
pn.panel(labels).show()
This runs, but the plot structure gets corrupted when trying to move a label. JS error: TypeError: Cannot read properties of undefined (reading '1')
Attempt 2: Trying to couple points locations to the label locations as a work around.
points = hv.Points(data)
stream = streams.PointDraw(data=points.columns(), source=points)
DataLink(points, labels)
pn.panel(points + labels).show()
When moving a point, the plot with the labels gets corrupted again.
Note that coupling two point sets does work in this way:
points2 = hv.Points(data)
stream = streams.PointDraw(data=points.columns(), source=points)
DataLink(points, points2)
pn.panel(points + points2).show()
So is it impossible to move labels dynamically or is there a mistake in my approach? Thanks.